user4331901
user4331901

Reputation:

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!

Upvotes: 0

Views: 208

Answers (1)

shirakia
shirakia

Reputation: 2409

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

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

Upvotes: 1

Related Questions