Edgars
Edgars

Reputation: 953

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.

Upvotes: 1

Views: 109

Answers (2)

Marek Lipka
Marek Lipka

Reputation: 51191

How about using String interpolation:

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

Upvotes: 2

yxf
yxf

Reputation: 493

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

Upvotes: 1

Related Questions