For the love of god, I've been banging my head on this for hours. Using rails3 rc, 1.9.2.
I'm trying to create a link_to that submits an ajax request, with parameters, a class and id, and needs a block so I can insert a span tag around the name. Documentation is of absolutely zero help, as are numerous google searches. Here's what I've got so far:
<%= link_to(
:url=>{
:controller => 'themes', :action => 'remove_tag',
:entity_id => entity_id, :theme_id => theme_id,
:entity => entity, :element_id => element_id, :parent_id=>parent_id
},
:remote => true,
:id => "theme-tag-#{entity}-#{entity_id}",
:class => "tag") do %>
<span class='subtract'><%= tag %></span>
<% end %>
The generated url looks like this:
<a href="/explore/index/theme-tag-user-3?url[controller]=themes&url[action]=remove_tag&url[entity_id]=3&url[theme_id]=16&url[entity]=user&url[element_id]=filter-contributor-3&url[parent_id]=filter-contributors&remote=true&class=tag">
Test descriptor
I can't indicate properly that the text "Test descriptor" is actually properly included within the span; code formatting is failing a little here, however, the href is wrong, there's no class or id, and downhill it continues to roll
If I didn't need the block, I could just add the name and not have to specify :url=>{...} (leaving if off throws an exception with the block, go figure) and then follow that with :remote=>true, :id=>"whatever", :class=>"blah" and it works. What am I doing wrong? Because I'm new to rails in general, I'd also like to understand why this syntax must differ so much? I mean really, thank god you don't have to write a lot of links like this in a web app... ;-)
Thanks in advance