DavidK
DavidK

Reputation: 319

Button not linking properly

For some reason this button is not linking correctly. could someone please show me what Im doing wrong?

<div class="btn-group">
   <button type="button" class="<%= @most_popular %> btn btn-default"><%= link_to "Most Popular", posts_path %></button>
</div>

Upvotes: 0

Views: 47

Answers (1)

Shakeeb Ahmad
Shakeeb Ahmad

Reputation: 2030

link_to creates an anchor tag. Reference.

Nesting anchor tag inside a button is not correct HTML afaik. If you want your link to look like a button you can try this. Bootstrap happily accepts all button classes on anchor tags.

<%= link_to 'Most Popular', posts_path, :class => "btn btn-default #{@most_popular}" %>

Upvotes: 1

Related Questions