I need to add a class attribute to the elements generated by link_to for my CSS to style the links. How can I do that?
<%= link_to "Artworks", :controller => "artwork", :action => "list" %>
I need to add a class attribute to the elements generated by link_to for my CSS to style the links. How can I do that?
<%= link_to "Artworks", :controller => "artwork", :action => "list" %>
dangerwillrobinsondanger wrote:
I need to add a class attribute to the elements generated by link_to for my CSS to style the links. How can I do that?
<%= link_to "Artworks", :controller => "artwork", :action => "list" %>
<%= link_to 'My Homepage', get_home_page.last, :class => 'navlink3' %>
Thanks, but that approach using this:
<%= link_to "Artworks", :controller => "artwork", :action => "list", :class => "artwork" %>
...generates this:
<a href="/artwork/list?class=artwork">Artworks</a>
That definitely renders, but renders something different from what I need. I need to generate this: <a href="/artwork/list" class="artwork">Artworks</a>
Aha!! I got it!
<%= link_to "Artworks", :controller => "artwork", :action => "list", :class => "artwork" %>
needs to be:
<%= link_to "Artworks", {:controller => "artwork", :action => "list"}, :class => "artwork" %>
Voila!