views:

187

answers:

1

Greetings,

I am trying to get a button to generate with id="view-blog-1-comments" and it seems the button_to_remote function is ignoring my call. Could some one set me straight on what I am doing wrong here.

<%= button_to_remote 'View Comments', :url => blog_comments_path(blog), :html => {:id => "view-blog-#{blog.id}-comments"}, :method => :get %>

Thanks in advance!

A: 

button_to_remote(name, options = {}, html_options = {})

is the method signature, so you need to rearrange your syntax to this:

button_to_remote 'View Comments', :url => blog_comments_path(blog), {:method => :get}, :id => "view-blog-#{blog.id}-comments"

Derek P.
Thank you. I actually had to change it to {:url => blog_comment_path(blog), :method=>:get}, :id =>"view-blog-#{blog.id}-comments". But your comment made me remember about how ruby collects key/value pairs together in function calls.
Adam T