Search code examples
ruby-on-railsrubylink-to

Rails - adding ruby code to link_to tag


Is there anyway to put the ruby code inside the link_to tag, like this:

<%= link_to '<%= b.name %>', {id: b.id, action: 'db_seemore'}%>

I am asking because i wanted to make link_to button with the name of the record which is redirecting the user to the record's page.

All help is appriciated!


Solution

  • In <% %> ruby code works. Just delete ''

    <%= link_to b.name, {id: b.id, action: 'db_seemore'}%>