Reputation:
I'm having trouble getting my links the way I want them. Currently, I have the following code:
<%= link_to :action => 'toggle' , :id => item.id, :remote => true do %>
<i class="icon icon-test"></i><b>Toggle</b>
<%end%>
This will produce the links that I want, but include &remote=true
in the link path instead of actually making the link ajaxy. Attempts to wrap parameters in parentheses or curly braces like
<%= link_to {:action => 'toggle', :remote => true }, :id => item.id do %> ...
gives me errors like
syntax error, unexpected tASSOC, expecting '}'
I'm thinking I want to make a call to the third signature listed here, but I can't seem to get the syntax right.
Upvotes: 0
Views: 389
Reputation: 107728
Rather than using hash arguments for the URL, you should really be using URL helpers:
<%= link_to toggle_item_path(item), :remote => true do %>
<i class="icon icon-test"></i><b>Toggle</b>
<% end %>
Not only is this shorter, but Rails will also not get confused what keys belong to what hash.
Read more in the Routing Guide
Upvotes: 1