I’m trying to make a link that goes to a user’s twitter account dynamically via a Twitter handle. The problem is the Twitter handle is just @variablehandle, not a full site link.
I figured out how to link to Facebook dynamically but Twitter was a fail, so maybe this can help you guys help me.
Both the Twitter and Facebook variables are present here. Also, we are using HAML:
- unless @user.facebook_url.blank?
%a{:href => @user.facebook_url}
click here
-unless @user.twitter_handle.blank?
%a{:href => "https://twitter.com/" + @user.twitter_handle}
click me
Use the
link_tohelper to make life easier: