Search code examples
ruby-on-railshyperlinklink-to

complex link with link_to rails


I want to put in single link_to these options.

<%= prods.manufacturer.name %> <%= prods.name %>

So that generated link would be together in single underline. Like Komptech Cribo900, that is one link. But at this moment I have 2 links and clickig on them sends me to manufacturer view or product view. I want to be able to go only to product view.

Product and Manufacturer models have relationship between them.

I tried <%= link_to (prods.manufacturer.name prods.name), prods%> and <%= link_to (prods.manufacturer.name)(prods.name), prods%> with errors. Is there any way to do this ?

Thanks.


Solution

  • How about using String interpolation:

    <%= link_to "#{prods.manufacturer.name} #{prods.name}", prods %>