Does anyone know if it''s possible to generate a link_to with :post => true and have extra params that do *not* appear in the url but still get passed to the controller. i.e. link_to { :controller => ''things'', :action => ''update'', :id => @thing, :translucency => 42 }, :post => true generates a post to the url /things/update/1?translucency=42 Looking at the source, I can see where rails is generating the imaginary form (f) with javascript var f = document.createElement(''form''); this.parentNode.appendChild(f); f.method = ''POST''; f.action = this.href; f.submit(); It doesn''t seem far fetched (to me) for Rails to be able to keep going and add an element to that form with something like... h = document.createElement(''input''); h.type = ''hidden''; h.name = ''translucency'', h.value = 42; f.appendChild(h) so that the url would simply become... /things/update/1 I know that I could just create the form myself, but that''s not as fun as having Rails do all the work for me. ;-) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jon Garvin wrote:> Does anyone know if it''s possible to generate a link_to with :post => > true and have extra params that do *not* appear in the url but still get > passed to the controller. i.e. > > link_to { :controller => ''things'', :action => ''update'', :id => @thing, > :translucency => 42 }, :post => true > >Actually, that was supposed to be... link_to { :controller => ''things'', :action => ''update'', :id => @thing, ''thing[translucency]'' => 42 }, :post => true --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jon Garvin wrote:> Does anyone know if it''s possible to generate a link_to with :post => > true and have extra params that do *not* appear in the url but still get > passed to the controller. i.e.You could write a custom helper to generate the javascript you need, or even better just use a redirect after your state changing action. You might be interested in the PRG pattern: http://en.wikipedia.org/wiki/Post/Redirect/Get zsombor -- Company - http://primalgrasp.com Thoughts - http://deezsombor.blogspot.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 -~----------~----~----~----~------~----~------~--~---