Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8359271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:05:38+00:00 2026-06-09T11:05:38+00:00

In my Rails app I have a user model (Devise) with url_field for Twitter.

  • 0

In my Rails app I have a user model (Devise) with url_field for Twitter.

Right now I have this in my show page:

<%= link_to @deal.user.company_twitter, @deal.user.company_twitter, :class => "comp_twitter" %>

It shows the entire link in the show page (even http://), that’s because my url_field makes the user add “http://&#8221; or it won’t validate the link.

I want the user to only add their “@name” instead of the whole Twitter link when creating their profile. I would also want to show only the @name instead of the Twitter link in the “show” page. How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:05:39+00:00Added an answer on June 9, 2026 at 11:05 am

    Simply don’t use an url_field, but a regular string database field, like twitter_username. When signing up, let the user enter their username, e.g. foo.

    For getting the real URL to the Twitter account, create a new method in your user.rb model:

    def twitter_url
      "http://twitter.com/#{self.twitter_username}"
    end
    

    The advantage is that at this point, in your model, you can include a custom validation that would check if this URL really exists after the user has submitted their twitter_username.

    Finally, use that in your view instead of just the URL:

    <%= link_to "@#{@user.twitter_username}", @user.twitter_url %>
    

    This would render:

    <a href="http://twitter.com/foo">@foo</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails app that is using Devise, with a User model, no
I have a rails app with devise for my user model. In my app
I have a Rails app, with 2 models : a User model and a
I have a Rails 3.1 app with a User model and a Venue model.
So I am using Devise for user authentication in my rails app. I have
We have a web app running on Rails, using Devise and OmniAuth for user
I'm building an app in Rails 3. I currently have a user model which
I am using Devise in Rails 3, and have a User model in rails
In my rails app I have a User model. In that model I have
I'm using Devise in a Rails 3 app, but in this case, a user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.