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>