EverTheLearner
EverTheLearner

Reputation: 7200

Link to external URL in Ruby on Rails

I'm trying to create a link to external website but am encountering an "Undefined method" runtime error with the code I've produced. What am I doing wrong?

show.html.erb:
<%= redirect_to "http://www.google.com", :class => "website_1" do %>

  <span class="s1">
    <span class="s2"><%= user.website %></span>
  </span>

<% end %>

Error:
undefined method `redirect_to' for #<#:0x00000102af1808>

I've tried link_to but I thought link_to is inherited from url_to which the purpose is to utilize routes?

Thanks!

Upvotes: 1

Views: 2470

Answers (2)

Nicolas Buduroi
Nicolas Buduroi

Reputation: 3584

You should use link_to not redirect_to!

Upvotes: 1

apneadiving
apneadiving

Reputation: 115521

redirect_to is not designed to create links, you should dive into link_to.

Doc here.

Upvotes: 2

Related Questions