Hi, I''m trying to emulate a post from a HTML form. I''ve the following code in erb: <h1>Alterar Password</h1> <% form_tag :action=>"reset_password", :method=>"put" do%> <p> <%=label_tag :password, "Nova password" %> </p> <p> <%=password_field_tag :password, @password %> </p> <p> <%=label_tag :password_confirmation, "Confirmação Password" %> </p> <p> <%=password_field_tag :password_confirmation, @password_confirmation %> </p> <%=submit_tag "Alterar Password" %> <%end %> In my action I have something similar to this: def reset_password if request.get? #do something for get elsif request.put? #do something for put else raise Webapp::BadRequestError end rescue Webapp::BadRequestError logger.error("Invalid Request type. Client IP: "+request.remote_ip) flash_error(:invalid_request) redirect_to root_url end I''ve functional tests for put and get, and everything is fine. But when the form is rendered and tested in a browser I can''t get this working. In Firefox, the output for the erb is something like: <form action="/user/reset_password/1/dd98e038fe7ab8570373307dfa710ecd86e782b00704dd172e546379acbf0a54?method=put" method="post"><div style="margin:0;padding:0;display:inline"><input name="authenticity_token" type="hidden" value="rOSsudVMJFZctILVNtSIyCfwJPvX4XOiUuLFxwZgyIA=" /></div> <p> <label for="password">Nova password</label> </p> <p> <input id="password" name="password" type="password" value="" /> </p> <p> <label for="password_confirmation">Confirmação Password</label> </p> <p> <input id="password_confirmation" name="password_confirmation" type="password" value="" /> </p> <input name="commit" type="submit" value="Alterar Password" /> </form> Everytime I submit the form I then hit in the Webapp::BadRequestError Can someone help me get over this? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I made some researche and found in Ruby on Rais guides that I''m doing the correct thing... but I''m not getting the correct results. I know I''m missing something... what is? http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work <http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work>Can you help? On Sat, Dec 12, 2009 at 8:22 PM, Jonhy Pear <jonhy.pear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''m trying to emulate a post from a HTML form. I''ve the following code in > erb: > > <h1>Alterar Password</h1> > <% form_tag :action=>"reset_password", :method=>"put" do%> > <p> > <%=label_tag :password, "Nova password" %> > </p> > <p> > <%=password_field_tag :password, @password %> > </p> > <p> > <%=label_tag :password_confirmation, "Confirmação Password" %> > </p> > <p> > <%=password_field_tag :password_confirmation, @password_confirmation %> > </p> > <%=submit_tag "Alterar Password" %> > <%end %> > > In my action I have something similar to this: > > > def reset_password > if request.get? > #do something for get > elsif request.put? > #do something for put > else > raise Webapp::BadRequestError > end > > rescue Webapp::BadRequestError > logger.error("Invalid Request type. Client IP: "+request.remote_ip) > flash_error(:invalid_request) > redirect_to root_url > end > > I''ve functional tests for put and get, and everything is fine. But when the > form is rendered and tested in a browser I can''t get this working. In > Firefox, the output for the erb is something like: > > <form > action="/user/reset_password/1/dd98e038fe7ab8570373307dfa710ecd86e782b00704dd172e546379acbf0a54?method=put" > method="post"><div style="margin:0;padding:0;display:inline"><input > name="authenticity_token" type="hidden" > value="rOSsudVMJFZctILVNtSIyCfwJPvX4XOiUuLFxwZgyIA=" /></div> > <p> > <label for="password">Nova password</label> > </p> > <p> > <input id="password" name="password" type="password" value="" /> > </p> > <p> > <label for="password_confirmation">Confirmação Password</label> > </p> > <p> > <input id="password_confirmation" name="password_confirmation" > type="password" value="" /> > </p> > <input name="commit" type="submit" value="Alterar Password" /> > </form> > > Everytime I submit the form I then hit in the Webapp::BadRequestError > > Can someone help me get over this? >-- João Miguel Pereira http://jpereira.eu LinkedIn: http://www.linkedin.com/in/joaomiguelpereira joaomiguel.pereira-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org (351) 96 275 68 58 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try '':method => :put'' (without the quotes). Rails is not always consistent. Some places either strings or symbols work, other places they don''t. HTH, Jeffrey Quoting Jonhy Pear <jonhy.pear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> I made some researche and found in Ruby on Rais guides that I''m doing the > correct thing... but I''m not getting the correct results. I know I''m missing > something... what is? > > http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work > > <http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work>Can > you help? > > On Sat, Dec 12, 2009 at 8:22 PM, Jonhy Pear <jonhy.pear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > > I''m trying to emulate a post from a HTML form. I''ve the following code in > > erb: > > > > <h1>Alterar Password</h1> > > <% form_tag :action=>"reset_password", :method=>"put" do%> > > <p> > > <%=label_tag :password, "Nova password" %> > > </p> > > <p> > > <%=password_field_tag :password, @password %> > > </p> > > <p> > > <%=label_tag :password_confirmation, "Confirmação Password" %> > > </p> > > <p> > > <%=password_field_tag :password_confirmation, @password_confirmation %> > > </p> > > <%=submit_tag "Alterar Password" %> > > <%end %> > > > > In my action I have something similar to this: > > > > > > def reset_password > > if request.get? > > #do something for get > > elsif request.put? > > #do something for put > > else > > raise Webapp::BadRequestError > > end > > > > rescue Webapp::BadRequestError > > logger.error("Invalid Request type. Client IP: "+request.remote_ip) > > flash_error(:invalid_request) > > redirect_to root_url > > end > > > > I''ve functional tests for put and get, and everything is fine. But when the > > form is rendered and tested in a browser I can''t get this working. In > > Firefox, the output for the erb is something like: > > > > <form > > action="/user/reset_password/1/dd98e038fe7ab8570373307dfa710ecd86e782b00704dd172e546379acbf0a54?method=put" > > method="post"><div style="margin:0;padding:0;display:inline"><input > > name="authenticity_token" type="hidden" > > value="rOSsudVMJFZctILVNtSIyCfwJPvX4XOiUuLFxwZgyIA=" /></div> > > <p> > > <label for="password">Nova password</label> > > </p> > > <p> > > <input id="password" name="password" type="password" value="" /> > > </p> > > <p> > > <label for="password_confirmation">Confirmação Password</label> > > </p> > > <p> > > <input id="password_confirmation" name="password_confirmation" > > type="password" value="" /> > > </p> > > <input name="commit" type="submit" value="Alterar Password" /> > > </form> > > > > Everytime I submit the form I then hit in the Webapp::BadRequestError > > > > Can someone help me get over this? > > > > > > -- > João Miguel Pereira > http://jpereira.eu > LinkedIn: http://www.linkedin.com/in/joaomiguelpereira > joaomiguel.pereira-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > (351) 96 275 68 58 > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
straightflush-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2009-Dec-13 05:01 UTC
Re: Re: How to make PUT with html forms?
there is a bug in 2.3.4 that breaks PUTs in Ajax calls, this could be your issue https://rails.lighthouseapp.com/projects/8994/tickets/2448-rails-23-json-put-request-routing-is-broken On Sat, Dec 12, 2009 at 10:57 PM, Jeffrey L. Taylor <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote:> Try '':method => :put'' (without the quotes). Rails is not always consistent. > Some places either strings or symbols work, other places they don''t. > > HTH, > Jeffrey > > Quoting Jonhy Pear <jonhy.pear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> I made some researche and found in Ruby on Rais guides that I''m doing the >> correct thing... but I''m not getting the correct results. I know I''m missing >> something... what is? >> >> http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work >> >> <http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work>Can >> you help? >> >> On Sat, Dec 12, 2009 at 8:22 PM, Jonhy Pear <jonhy.pear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> > Hi, >> > >> > I''m trying to emulate a post from a HTML form. I''ve the following code in >> > erb: >> > >> > <h1>Alterar Password</h1> >> > <% form_tag :action=>"reset_password", :method=>"put" do%> >> > <p> >> > <%=label_tag :password, "Nova password" %> >> > </p> >> > <p> >> > <%=password_field_tag :password, @password %> >> > </p> >> > <p> >> > <%=label_tag :password_confirmation, "Confirmação Password" %> >> > </p> >> > <p> >> > <%=password_field_tag :password_confirmation, @password_confirmation %> >> > </p> >> > <%=submit_tag "Alterar Password" %> >> > <%end %> >> > >> > In my action I have something similar to this: >> > >> > >> > def reset_password >> > if request.get? >> > #do something for get >> > elsif request.put? >> > #do something for put >> > else >> > raise Webapp::BadRequestError >> > end >> > >> > rescue Webapp::BadRequestError >> > logger.error("Invalid Request type. Client IP: "+request.remote_ip) >> > flash_error(:invalid_request) >> > redirect_to root_url >> > end >> > >> > I''ve functional tests for put and get, and everything is fine. But when the >> > form is rendered and tested in a browser I can''t get this working. In >> > Firefox, the output for the erb is something like: >> > >> > <form >> > action="/user/reset_password/1/dd98e038fe7ab8570373307dfa710ecd86e782b00704dd172e546379acbf0a54?method=put" >> > method="post"><div style="margin:0;padding:0;display:inline"><input >> > name="authenticity_token" type="hidden" >> > value="rOSsudVMJFZctILVNtSIyCfwJPvX4XOiUuLFxwZgyIA=" /></div> >> > <p> >> > <label for="password">Nova password</label> >> > </p> >> > <p> >> > <input id="password" name="password" type="password" value="" /> >> > </p> >> > <p> >> > <label for="password_confirmation">Confirmação Password</label> >> > </p> >> > <p> >> > <input id="password_confirmation" name="password_confirmation" >> > type="password" value="" /> >> > </p> >> > <input name="commit" type="submit" value="Alterar Password" /> >> > </form> >> > >> > Everytime I submit the form I then hit in the Webapp::BadRequestError >> > >> > Can someone help me get over this? >> > >> >> >> >> -- >> João Miguel Pereira >> http://jpereira.eu >> LinkedIn: http://www.linkedin.com/in/joaomiguelpereira >> joaomiguel.pereira-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >> (351) 96 275 68 58 >> >> -- >> >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thank you. I tried just that now. But still produce the same result: <form action=" /user/reset_password/1/b5fa7579f3d3e10723e997b1300b2521ef7c5774958c56ff4b035be2f95b2cdd?method=put" method="post"><div style="margin:0;padding:0;display:inline"><input name=" authenticity_token" type="hidden" value=" rOSsudVMJFZctILVNtSIyCfwJPvX4XOiUuLFxwZgyIA=" /> And no hidden field named _method, as stated in documentation. On Sun, Dec 13, 2009 at 3:57 AM, Jeffrey L. Taylor <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org>wrote:> Try '':method => :put'' (without the quotes). Rails is not always > consistent. > Some places either strings or symbols work, other places they don''t. > > HTH, > Jeffrey > > Quoting Jonhy Pear <jonhy.pear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > I made some researche and found in Ruby on Rais guides that I''m doing the > > correct thing... but I''m not getting the correct results. I know I''m > missing > > something... what is? > > > > > http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work > > > > < > http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work > >Can > > you help? > > > > On Sat, Dec 12, 2009 at 8:22 PM, Jonhy Pear <jonhy.pear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > Hi, > > > > > > I''m trying to emulate a post from a HTML form. I''ve the following code > in > > > erb: > > > > > > <h1>Alterar Password</h1> > > > <% form_tag :action=>"reset_password", :method=>"put" do%> > > > <p> > > > <%=label_tag :password, "Nova password" %> > > > </p> > > > <p> > > > <%=password_field_tag :password, @password %> > > > </p> > > > <p> > > > <%=label_tag :password_confirmation, "Confirmação Password" %> > > > </p> > > > <p> > > > <%=password_field_tag :password_confirmation, > @password_confirmation %> > > > </p> > > > <%=submit_tag "Alterar Password" %> > > > <%end %> > > > > > > In my action I have something similar to this: > > > > > > > > > def reset_password > > > if request.get? > > > #do something for get > > > elsif request.put? > > > #do something for put > > > else > > > raise Webapp::BadRequestError > > > end > > > > > > rescue Webapp::BadRequestError > > > logger.error("Invalid Request type. Client IP: "+request.remote_ip) > > > flash_error(:invalid_request) > > > redirect_to root_url > > > end > > > > > > I''ve functional tests for put and get, and everything is fine. But when > the > > > form is rendered and tested in a browser I can''t get this working. In > > > Firefox, the output for the erb is something like: > > > > > > <form > > > > action="/user/reset_password/1/dd98e038fe7ab8570373307dfa710ecd86e782b00704dd172e546379acbf0a54?method=put" > > > method="post"><div style="margin:0;padding:0;display:inline"><input > > > name="authenticity_token" type="hidden" > > > value="rOSsudVMJFZctILVNtSIyCfwJPvX4XOiUuLFxwZgyIA=" /></div> > > > <p> > > > <label for="password">Nova password</label> > > > </p> > > > <p> > > > <input id="password" name="password" type="password" value="" /> > > > </p> > > > <p> > > > <label for="password_confirmation">Confirmação Password</label> > > > </p> > > > <p> > > > <input id="password_confirmation" name="password_confirmation" > > > type="password" value="" /> > > > </p> > > > <input name="commit" type="submit" value="Alterar Password" /> > > > </form> > > > > > > Everytime I submit the form I then hit in the Webapp::BadRequestError > > > > > > Can someone help me get over this? > > > > > > > > > > > -- > > João Miguel Pereira > > http://jpereira.eu > > LinkedIn: http://www.linkedin.com/in/joaomiguelpereira > > joaomiguel.pereira-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > > (351) 96 275 68 58 > > > > -- > > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ok, thank you. My form is not AJAXified. I managed to fix the problem. It probably has something to do with the rendering of the form using form_tag. If I have hardcoded the hidden field, everything is fine: <%=password_field_tag :password_confirmation, @password_confirmation %> This is a hack and I would like to know if you now something about this. On Sun, Dec 13, 2009 at 5:01 AM, straightflush-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org < straightflush-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> there is a bug in 2.3.4 that breaks PUTs in Ajax calls, this could be your > issue > > > https://rails.lighthouseapp.com/projects/8994/tickets/2448-rails-23-json-put-request-routing-is-broken > > On Sat, Dec 12, 2009 at 10:57 PM, Jeffrey L. Taylor > <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote: > > Try '':method => :put'' (without the quotes). Rails is not always > consistent. > > Some places either strings or symbols work, other places they don''t. > > > > HTH, > > Jeffrey > > > > Quoting Jonhy Pear <jonhy.pear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > >> I made some researche and found in Ruby on Rais guides that I''m doing > the > >> correct thing... but I''m not getting the correct results. I know I''m > missing > >> something... what is? > >> > >> > http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work > >> > >> < > http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work > >Can > >> you help? > >> > >> On Sat, Dec 12, 2009 at 8:22 PM, Jonhy Pear <jonhy.pear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > >> > >> > Hi, > >> > > >> > I''m trying to emulate a post from a HTML form. I''ve the following code > in > >> > erb: > >> > > >> > <h1>Alterar Password</h1> > >> > <% form_tag :action=>"reset_password", :method=>"put" do%> > >> > <p> > >> > <%=label_tag :password, "Nova password" %> > >> > </p> > >> > <p> > >> > <%=password_field_tag :password, @password %> > >> > </p> > >> > <p> > >> > <%=label_tag :password_confirmation, "Confirmação Password" %> > >> > </p> > >> > <p> > >> > <%=password_field_tag :password_confirmation, > @password_confirmation %> > >> > </p> > >> > <%=submit_tag "Alterar Password" %> > >> > <%end %> > >> > > >> > In my action I have something similar to this: > >> > > >> > > >> > def reset_password > >> > if request.get? > >> > #do something for get > >> > elsif request.put? > >> > #do something for put > >> > else > >> > raise Webapp::BadRequestError > >> > end > >> > > >> > rescue Webapp::BadRequestError > >> > logger.error("Invalid Request type. Client IP: > "+request.remote_ip) > >> > flash_error(:invalid_request) > >> > redirect_to root_url > >> > end > >> > > >> > I''ve functional tests for put and get, and everything is fine. But > when the > >> > form is rendered and tested in a browser I can''t get this working. In > >> > Firefox, the output for the erb is something like: > >> > > >> > <form > >> > > action="/user/reset_password/1/dd98e038fe7ab8570373307dfa710ecd86e782b00704dd172e546379acbf0a54?method=put" > >> > method="post"><div style="margin:0;padding:0;display:inline"><input > >> > name="authenticity_token" type="hidden" > >> > value="rOSsudVMJFZctILVNtSIyCfwJPvX4XOiUuLFxwZgyIA=" /></div> > >> > <p> > >> > <label for="password">Nova password</label> > >> > </p> > >> > <p> > >> > <input id="password" name="password" type="password" value="" /> > >> > </p> > >> > <p> > >> > <label for="password_confirmation">Confirmação Password</label> > >> > </p> > >> > <p> > >> > <input id="password_confirmation" name="password_confirmation" > >> > type="password" value="" /> > >> > </p> > >> > <input name="commit" type="submit" value="Alterar Password" /> > >> > </form> > >> > > >> > Everytime I submit the form I then hit in the Webapp::BadRequestError > >> > > >> > Can someone help me get over this? > >> > > >> > >> > >> > >> -- > >> João Miguel Pereira > >> http://jpereira.eu > >> LinkedIn: http://www.linkedin.com/in/joaomiguelpereira > >> joaomiguel.pereira-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > >> (351) 96 275 68 58 > >> > >> -- > >> > >> 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<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > >> For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >> > >> > > > > -- > > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > > > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Why don''t you create a controller for ''reset_password'', using RESTfull methods. Use ''new'' action for the GET and ''update'' for PUT. 2009/12/13 João Pereira <joaomiguel.pereira-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> Ok, thank you. My form is not AJAXified. I managed to fix the problem. It > probably has something to do with the rendering of the form using form_tag. > If I have hardcoded the hidden field, everything is fine: > > <%=password_field_tag :password_confirmation, @password_confirmation %> > > This is a hack and I would like to know if you now something about this. > > > > > On Sun, Dec 13, 2009 at 5:01 AM, straightflush-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org < > straightflush-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> there is a bug in 2.3.4 that breaks PUTs in Ajax calls, this could be your >> issue >> >> >> https://rails.lighthouseapp.com/projects/8994/tickets/2448-rails-23-json-put-request-routing-is-broken >> >> On Sat, Dec 12, 2009 at 10:57 PM, Jeffrey L. Taylor >> <ror-f/t7CGFWhwGcvWdFBKKxig@public.gmane.org> wrote: >> > Try '':method => :put'' (without the quotes). Rails is not always >> consistent. >> > Some places either strings or symbols work, other places they don''t. >> > >> > HTH, >> > Jeffrey >> > >> > Quoting Jonhy Pear <jonhy.pear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> >> I made some researche and found in Ruby on Rais guides that I''m doing >> the >> >> correct thing... but I''m not getting the correct results. I know I''m >> missing >> >> something... what is? >> >> >> >> >> http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work >> >> >> >> < >> http://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-put-or-delete-methods-work >> >Can >> >> you help? >> >> >> >> On Sat, Dec 12, 2009 at 8:22 PM, Jonhy Pear <jonhy.pear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >> >> >> >> > Hi, >> >> > >> >> > I''m trying to emulate a post from a HTML form. I''ve the following >> code in >> >> > erb: >> >> > >> >> > <h1>Alterar Password</h1> >> >> > <% form_tag :action=>"reset_password", :method=>"put" do%> >> >> > <p> >> >> > <%=label_tag :password, "Nova password" %> >> >> > </p> >> >> > <p> >> >> > <%=password_field_tag :password, @password %> >> >> > </p> >> >> > <p> >> >> > <%=label_tag :password_confirmation, "Confirmação Password" %> >> >> > </p> >> >> > <p> >> >> > <%=password_field_tag :password_confirmation, >> @password_confirmation %> >> >> > </p> >> >> > <%=submit_tag "Alterar Password" %> >> >> > <%end %> >> >> > >> >> > In my action I have something similar to this: >> >> > >> >> > >> >> > def reset_password >> >> > if request.get? >> >> > #do something for get >> >> > elsif request.put? >> >> > #do something for put >> >> > else >> >> > raise Webapp::BadRequestError >> >> > end >> >> > >> >> > rescue Webapp::BadRequestError >> >> > logger.error("Invalid Request type. Client IP: >> "+request.remote_ip) >> >> > flash_error(:invalid_request) >> >> > redirect_to root_url >> >> > end >> >> > >> >> > I''ve functional tests for put and get, and everything is fine. But >> when the >> >> > form is rendered and tested in a browser I can''t get this working. In >> >> > Firefox, the output for the erb is something like: >> >> > >> >> > <form >> >> > >> action="/user/reset_password/1/dd98e038fe7ab8570373307dfa710ecd86e782b00704dd172e546379acbf0a54?method=put" >> >> > method="post"><div style="margin:0;padding:0;display:inline"><input >> >> > name="authenticity_token" type="hidden" >> >> > value="rOSsudVMJFZctILVNtSIyCfwJPvX4XOiUuLFxwZgyIA=" /></div> >> >> > <p> >> >> > <label for="password">Nova password</label> >> >> > </p> >> >> > <p> >> >> > <input id="password" name="password" type="password" value="" /> >> >> > </p> >> >> > <p> >> >> > <label for="password_confirmation">Confirmação Password</label> >> >> > </p> >> >> > <p> >> >> > <input id="password_confirmation" name="password_confirmation" >> >> > type="password" value="" /> >> >> > </p> >> >> > <input name="commit" type="submit" value="Alterar Password" /> >> >> > </form> >> >> > >> >> > Everytime I submit the form I then hit in the Webapp::BadRequestError >> >> > >> >> > Can someone help me get over this? >> >> > >> >> >> >> >> >> >> >> -- >> >> João Miguel Pereira >> >> http://jpereira.eu >> >> LinkedIn: http://www.linkedin.com/in/joaomiguelpereira >> >> joaomiguel.pereira-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >> >> (351) 96 275 68 58 >> >> >> >> -- >> >> >> >> 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm >> . >> >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >> >> >> > >> > -- >> > >> > 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<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> > For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > >> > >> > >> >> -- >> >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >> > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Andrei Erdoss -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
i am worry what i nogood cumpiuter but ok On Sat, Dec 12, 2009 at 11:52 PM, Jonhy Pear <jonhy.pear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''m trying to emulate a post from a HTML form. I''ve the following code in > erb: > > <h1>Alterar Password</h1> > <% form_tag :action=>"reset_password", :method=>"put" do%> > <p> > <%=label_tag :password, "Nova password" %> > </p> > <p> > <%=password_field_tag :password, @password %> > </p> > <p> > <%=label_tag :password_confirmation, "Confirmação Password" %> > </p> > <p> > <%=password_field_tag :password_confirmation, @password_confirmation %> > </p> > <%=submit_tag "Alterar Password" %> > <%end %> > > In my action I have something similar to this: > > > def reset_password > if request.get? > #do something for get > elsif request.put? > #do something for put > else > raise Webapp::BadRequestError > end > > rescue Webapp::BadRequestError > logger.error("Invalid Request type. Client IP: "+request.remote_ip) > flash_error(:invalid_request) > redirect_to root_url > end > > I''ve functional tests for put and get, and everything is fine. But when the > form is rendered and tested in a browser I can''t get this working. In > Firefox, the output for the erb is something like: > > <form > action="/user/reset_password/1/dd98e038fe7ab8570373307dfa710ecd86e782b00704dd172e546379acbf0a54?method=put" > method="post"><div style="margin:0;padding:0;display:inline"><input > name="authenticity_token" type="hidden" > value="rOSsudVMJFZctILVNtSIyCfwJPvX4XOiUuLFxwZgyIA=" /></div> > <p> > <label for="password">Nova password</label> > </p> > <p> > <input id="password" name="password" type="password" value="" /> > </p> > <p> > <label for="password_confirmation">Confirmação Password</label> > </p> > <p> > <input id="password_confirmation" name="password_confirmation" > type="password" value="" /> > </p> > <input name="commit" type="submit" value="Alterar Password" /> > </form> > > Everytime I submit the form I then hit in the Webapp::BadRequestError > > Can someone help me get over this? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.