Reputation: 406
Hello I have this link_to and I can't figure out how to wrap a block of html code in it such that the div inside the link_to becomes a link. I have this code:
<%= link_to @favorites[0].name, {:controller => "events", :action => "search", :category => @favorites[0].name} %>
I have tried using "do" then <%end%> but I can't make it work.
<%= link_to @favorites[0].name, {:controller => "events", :action => "search", :category => @favorites[0].name} do %>
<div> CODE HERE</div>
<%end%>
Any ideas on how to do this? I do not understand the syntax.
Upvotes: 1
Views: 521
Reputation: 1424
You need to give only path
with link_to
when using the block
.
<%= link_to({:controller => "events", :action => "search", :category => @favorites[0].name}) do %>
<div>
<%= @favorites[0].name %>
</div>
<%end%>
Upvotes: 3