Reputation: 138
I have a string field in my User table where I store the user's github website url. Now, I am trying to show the link on the user's profile page. Instead of getting 'https://www.github.com'(example link)...I am getting "localhost/users/www.github.com". I tried it the following way :-
<% if @user.github? %>
<a href="<%= "#{@user.github}" %>"><i class="fa fa-github-alt"></i></a>
<% end %>
On clicking the link, I get localhost/users/www.github.com instead of just www.github.com. How can this be done correctly ?
Upvotes: 0
Views: 41
Reputation: 2541
Your url is without the "https://". you can try following or save it all urs with "https://","http://"
<% if @user.github? %>
<a href="<%= "https://#{@user.github}" %>"><i class="fa fa-github-alt"></i></a>
<% end %>
Upvotes: 2