This has to be really simple but I’m stuck.
I have two fields fname and lname that I want to put together and use as the link to the Show method.
<%= link_to 'Show', person %>
<%= link_to person.fname %> <%= person.lname %>
The top line links to where I need it to go. But, the second line displays the first and last name the way I want it to, though it doesn’t link to the specific record, just the index page.
How can I have the second line link to the specific record?
Thanks
Scott
Try this:
Whay you have inadvertantly done is split the link into to different parts by adding two <%= %> delimiters. What you need to do is join the fname and lname together as the first argument of the link_to, and they supply the object as the second argument so link_to knows what link to generate.
As an aside, a faster way to join strings together is to use interpolation: