Damjan Rems
2013-Apr-14 16:13 UTC
How todiffer if params are set through form or through url
Is there a way to differ if params are set through form submit: <%= form_tag action: ''login'', method: :put do %> <%= text_field(''record'',''username'') %> <%= password_field(''record'',''password'') %> <%= submit_tag %> or through url http://some.site/login?record[username]=user&record[password]=pwd In both cases they appear in controller as params[:record][:user] and params[:record][:password] The idea is to prevent the second scenario. by TheR -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Apr-14 16:21 UTC
Re: How todiffer if params are set through form or through url
On 14 April 2013 17:13, Damjan Rems <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Is there a way to differ if params are set through form submit: > > <%= form_tag action: ''login'', method: :put do %> > <%= text_field(''record'',''username'') %> > <%= password_field(''record'',''password'') %> > <%= submit_tag %> > > or through url > > http://some.site/login?record[username]=user&record[password]=pwd > > In both cases they appear in controller as params[:record][:user] and > params[:record][:password]The second one will appear as a GET, not a POST. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Frederick Cheung
2013-Apr-15 07:18 UTC
Re: How todiffer if params are set through form or through url
On Sunday, April 14, 2013 5:13:11 PM UTC+1, Ruby-Forum.com User wrote:> Is there a way to differ if params are set through form submit: > > or through url > > http://some.site/login?record[username]=user&record[password]=pwd > > In both cases they appear in controller as params[:record][:user] and > > params[:record][:password] > > The idea is to prevent the second scenario. >If I only wanted an action to be accessible via the put method, I''d setup the corresponding route(s) to enforce that for me (ie don''t use match, use the verb you actually expect) Fred> > by > > TheR > > > > -- > > 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/2pigH5hTKscJ. For more options, visit https://groups.google.com/groups/opt_out.