0

I'd like to have something like this as output:

<a href="...">See Los Angeles</a> or

<a href="...">See New York</a> etc, so New York and Los Angeles would be a variable.

How can I achieve that with Rails? I read something and tried this, but it didn't work:

<%= link_to 'See #{@city.name}', @city  %>

Thanks!

watt
  • 799
  • 3
  • 8
  • 22

1 Answers1

2

Nevermind, the above solution works but I had to put double quotes, not single. So this is the solution:

<%= link_to "See #{@city.name}", @city  %>
watt
  • 799
  • 3
  • 8
  • 22
  • 1
    That's because ruby does not parse variables inside single quotes, only inside double quotes. It's called string interpolation: http://stackoverflow.com/questions/6395288/ruby-double-vs-single-quotes – Rafael Oliveira Oct 29 '13 at 13:01