laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Feb-14 17:19 UTC
How do I access this parameter?
Hi, I have a form for creating users ... <% form_tag ''userconfirm'' do -%> <!-- more code --> <p><label for="user_login">Username</label><br/> <%= text_field ''user'', ''login'' %></p> <p><label for="user_password">Password</label><br/> <%= password_field ''user'', ''password'' %></p> <p><label for="password_confirmation">Confirm Password</label><br/> <%= password_field ''user'', ''password_confirmation'' %></p> <% end -%> My question is, on the controller end, how do I access the parameter for login and password? I thought it would be params[:login] and params[:password], but that is not right. Any help is appreciated, - Dave My code now: def userconfirm @user = User.new(params[:user]) if @user.save # Create session if (log_user_in(params[:login], params[:password], nil)) redirect_to :controller => ''order'', :action => ''new'' else flash[:notice] = "You are not logged in." redirect_to :action => "start" end else render :action => ''userinfo'' end end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 14 Feb 2008, at 17:19, laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote:> > Hi, > > I have a form for creating users ... > > <% form_tag ''userconfirm'' do -%> > <!-- more code --> > <p><label for="user_login">Username</label><br/> > <%= text_field ''user'', ''login'' %></p> > > <p><label for="user_password">Password</label><br/> > <%= password_field ''user'', ''password'' %></p> > > <p><label for="password_confirmation">Confirm Password</label><br/> > <%= password_field ''user'', ''password_confirmation'' %></p> > <% end -%> >Just take a look in your log files and you''ll see that they arrive as params[:user][:login], params[:user][:password] Fred> My question is, on the controller end, how do I access the parameter > for login and password? I thought it would be params[:login] and > params[:password], but that is not right. Any help is appreciated, - > Dave > > > My code now: > > def userconfirm > @user = User.new(params[:user]) > if @user.save > # Create session > if (log_user_in(params[:login], > params[:password], nil)) > redirect_to :controller => > ''order'', :action => ''new'' > else > flash[:notice] = "You are not logged > in." > redirect_to :action => "start" > end > else > render :action => ''userinfo'' > end > end > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Add the following if you are unsure in the controller method of interest: puts params.inspect it will dump the values to the console as another option to check... -- 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 -~----------~----~----~----~------~----~------~--~---
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Feb-14 19:10 UTC
Re: How do I access this parameter?
Thanks for your help. It was indeed params[:user][:login]. I didn''t know I could use the log file so I''m grateful also for that info, - Dave On Feb 14, 11:35 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 14 Feb 2008, at 17:19, laredotorn...-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote: > > > > > > > > > Hi, > > > I have a form for creating users ... > > > <% form_tag ''userconfirm'' do -%> > > <!-- more code --> > > <p><label for="user_login">Username</label><br/> > > <%= text_field ''user'', ''login'' %></p> > > > <p><label for="user_password">Password</label><br/> > > <%= password_field ''user'', ''password'' %></p> > > > <p><label for="password_confirmation">Confirm Password</label><br/> > > <%= password_field ''user'', ''password_confirmation'' %></p> > > <% end -%> > > Just take a look in your log files and you''ll see that they arrive as > params[:user][:login], params[:user][:password] > > Fred > > > > > My question is, on the controller end, how do I access the parameter > > for login and password? I thought it would be params[:login] and > > params[:password], but that is not right. Any help is appreciated, - > > Dave > > > My code now: > > > def userconfirm > > @user = User.new(params[:user]) > > if @user.save > > # Create session > > if (log_user_in(params[:login], > > params[:password], nil)) > > redirect_to :controller => > > ''order'', :action => ''new'' > > else > > flash[:notice] = "You are not logged > > in." > > redirect_to :action => "start" > > end > > else > > render :action => ''userinfo'' > > end > > end- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If you are using rails 2, you can also use the debugger which is a TON of help. start script/server with --debugger and put "debugger" on the line you want it to stop on. Then you can inspect variables, step, and even evaluate routines. WAY cool!! --Alan On Thu, Feb 14, 2008 at 1:10 PM, laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org < laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org> wrote:> > Thanks for your help. It was indeed params[:user][:login]. I didn''t > know I could use the log file so I''m grateful also for that info, - > Dave > > On Feb 14, 11:35 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > On 14 Feb 2008, at 17:19, laredotorn...-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote: > > > > > > > > > > > > > > > > > Hi, > > > > > I have a form for creating users ... > > > > > <% form_tag ''userconfirm'' do -%> > > > <!-- more code --> > > > <p><label for="user_login">Username</label><br/> > > > <%= text_field ''user'', ''login'' %></p> > > > > > <p><label for="user_password">Password</label><br/> > > > <%= password_field ''user'', ''password'' %></p> > > > > > <p><label for="password_confirmation">Confirm Password</label><br/> > > > <%= password_field ''user'', ''password_confirmation'' %></p> > > > <% end -%> > > > > Just take a look in your log files and you''ll see that they arrive as > > params[:user][:login], params[:user][:password] > > > > Fred > > > > > > > > > My question is, on the controller end, how do I access the parameter > > > for login and password? I thought it would be params[:login] and > > > params[:password], but that is not right. Any help is appreciated, - > > > Dave > > > > > My code now: > > > > > def userconfirm > > > @user = User.new(params[:user]) > > > if @user.save > > > # Create session > > > if (log_user_in(params[:login], > > > params[:password], nil)) > > > redirect_to :controller => > > > ''order'', :action => ''new'' > > > else > > > flash[:notice] = "You are not logged > > > in." > > > redirect_to :action => "start" > > > end > > > else > > > render :action => ''userinfo'' > > > end > > > end- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text - > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---