I have a loop that links to every item in a collection:
<% current_user.projects.all.each do |p| %>
<%= link_to p.name, project_path(p), :class => current_class?(project_path(p)), :id => p.theme %>
<% end %>
Right now, I’m assigning a class for the anchor in addition to an id so I can apply some CSS. Really though, it would make more sense for me to have this as a double classed anchor. Is there a way to assign two classes to the same object with the link_to helper?
Just separate them by spaces, as you would in ordinary HTML.
You can generate the string however you want. If you have the classes you want as an array you could use
some_classes.join(" ")to combine them.