Search code examples
ruby-on-rails-3http-redirecthyperlinkpermalinks

How to redirect to a permalink that is stored as a column in my model


I am building something where contributors can post content to my site. I want to create a link where other users can click on and bring the user to the respective contributor's own website. The permalink for each contributor's website is a column in my contributor model.

Everything I tried so far just appends the contributor's permalink to the end of the existing URL. ie, www.mysite.com/xxx/www.contributorsite.com instead of just redirecting to www.contributorcite.com

Please help


Solution

  • Try something like this (should probably build the link in the controller instead of model, or just append http:// to the user entered info):

    <% link = "http://"+user.permalink %>
    <%= link_to "Users website", link %>