def test if request.post? render :text => "post" else render :text => "other" end end when i post with a form to this page - goes into else branch, when trying to output request.post? - it''s false -- 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.
On Wed, Aug 17, 2011 at 8:42 AM, art <artem82-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> when i post with a form to this page - goes into else branch, when > trying to output request.post? - it''s falseAre you sure you''re not actually doing a PUT via hidden form fields? -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- 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.
It works fine for me. Here is my code: <form method="post" action="/pages/test"> <div><input type="text" name="email" value="enter email"/></div> <div><button type="submit" name="submit">Submit</button></div> </form> == Test2App::Application.routes.draw do root :to => "pages#home" post ''pages/test'' == class PagesController < ApplicationController def test if request.post? render :text => "post" else render :text => "other" end end end When I click the submit button, ''post'' appears in the new page that loads in my browser. -- 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-/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.
Hassan Schroeder wrote in post #1017170:> On Wed, Aug 17, 2011 at 8:42 AM, art <artem82-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> when i post with a form to this page - goes into else branch, when >> trying to output request.post? - it''s false > > Are you sure you''re not actually doing a PUT via hidden form fields? >Try this: def test render :text => request.method end -- 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-/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.
render :text => request.method # --> ''POST'' and yet render :text => request.post? # --> false rails 3.0.9 On Aug 17, 9:11 pm, 7stud -- <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hassan Schroeder wrote in post #1017170: > > > On Wed, Aug 17, 2011 at 8:42 AM, art <arte...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> when i post with a form to this page - goes into else branch, when > >> trying to output request.post? - it''s false > > > Are you sure you''re not actually doing a PUT via hidden form fields? > > Try this: > > def test > > render :text => request.method > > end > > -- > Posted viahttp://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-/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.
Yes, it is a put via hidden field, but how did a hidden field got there in a first place?? On Aug 17, 9:00 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, Aug 17, 2011 at 8:42 AM, art <arte...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > when i post with a form to this page - goes into else branch, when > > trying to output request.post? - it''s false > > Are you sure you''re not actually doing a PUT via hidden form fields? > > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe80Tx58lXaADg@public.gmane.org://about.me/hassanschroeder > twitter: @hassan-- 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.
art wrote in post #1017184:> Yes, it is a put via hidden field, > > but how did a hidden field got there in a first place?? >Post the code that creates your form. -- 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-/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.
art wrote in post #1017180:> render :text => request.method # --> ''POST'' > > and yet > render :text => request.post? # --> false > > rails 3.0.9Okay. Web browser can''t really send PUT or DELETE requests. So rails fakes it by putting a hidden form field on the page with a value of ''put'' or ''delete''. Then rails checks for that form field. I guess request.method returns the actual type of the request that the browser sent--not the type that rails fakes. -- 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-/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.