Hi I’m trying to create a pretty complex link where I need it too look like this <a><li>Link text</li></a>. Right now I have this:
<% ["Philosophy", "Team", "Local Vendors"].each do |link_name| %>
<% if params[:action] == link_name.downcase.sub(" ", "_") %>
<%= link_to {:controller => :philosophy, :action => link_name.downcase.sub(" ", "_").to_sym}, {:class => "selected"} do %>
<li><%= link_name %></li>
<% end %>
<% else %>
<%= link_to :controller => :philosophy, :action => link_name.downcase.sub(" ", "_").to_sym do %>
<li><%= link_name %></li>
<% end %>
<% end %>
But instead of producing a link that looks like <a href="philosophy/philosophy" class="selected"><li>Philosophy</li></a> it is giving me
<a href="/philosophy/philosophy?class=selected">
<li>Philosophy</li>
</a>
Can anyone help?
I think this will resolve your issue:
I’m surprised you’re not getting an error at that line without the surrounding parenthesis.