chriso1515-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-21 04:01 UTC
noob with :method => :post vs. :post => ''true'' dilemma
Okay, I''ve worked through the tutorial in 2nd ed. Agile Dev book. And I think I understand the methods concerning user management; however, when I use :method => :post in my app, I get a link of the following variety: <li><a href="/login/delete_user/2" method="post" onclick="return confirm(''Really delete john?'');">[X]</a> john </li> Note the ''method="post"'', and in my log when I click this thing, no ''post'' goes through, and no user gets deleted. My delete_user method is identical to book''s. However, when I use :post => ''true'', no problem; post shows up in log, and user gets deleted. Generated code looks like: <li><a href="/login/delete_user/1" onclick="if (confirm(''Really delete john?'')) { var f = document.createElement(''form''); this.parentNode.appendChild(f); f.method = ''POST''; f.action this.href; f.submit(); };return false;">[X]</a> john </li> What''s even stranger to me is that if I download the book''s code, which has :method => :post in its list_users.rhtml template, and run that app, it works just fine. What am I missing? I''m on rails 1.2.1, but am really bewildered about the difference here. Thanks for your patience. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Per Velschow
2007-Jan-22 05:29 UTC
Re: noob with :method => :post vs. :post => ''true'' dilemma
You should post the exact code that you are using. However, you are most likely passing the arguments to the helper method incorrectly. They have a rather strange parameter profile and you have to take great care where you put the arguments and sometimes you need to explicitly surround them with braces. The best example is probably directly from the Rails API docs: link_to "Delete Image", { :action => "delete", :id => @image.id }, :confirm => "Are you sure?", :method => :delete Notice how the second argument is explicitly made into a Hash using braces. The remaining arguments are implicitly turned into another Hash by Ruby and will be passed as the third argument. If this doesn''t solve your problem, then post your exact code that misbehaves. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---