Choylton B. Higginbottom
Choylton B. Higginbottom

Reputation: 2304

Can't add class to Rails link_to

I tried to add a simple HTML class to my link_to tag:

<%= link_to "Individual Images", action: 'feature_highlights', site_title: site.title, class: "btn" %>

..but it gets appended to the URL instead:

How do I add a class to my link_to tag?

Upvotes: 1

Views: 160

Answers (1)

Choylton B. Higginbottom
Choylton B. Higginbottom

Reputation: 2304

As per the API docs:

Be careful when using the older argument style, as an extra literal hash is needed

So, the solution was

<%= link_to "Individual Images", { action: 'feature_highlights', site_title: site.title }, class: "btn" %>

Upvotes: 1

Related Questions