I''m following the agile development book by Dave Thomas and group. <%= text_field ''user'', ''email'' %> translates into <input id="user_email" name="user[email]" size="30" type="text" value="a@a.com" /> Now I want to retrieve the value of the email address. How do I get the value. I tried different combinations of params[''user[email]''] but it''s not working. If I use @user = User.new(params[:user]) everything works but I just want the value of email address? thanks. -=- Neeraj _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Friday 21 October 2005 02:06, Neeraj Kumar wrote:> I''m following the agile development book by Dave Thomas and group. > > <%= text_field ''user'', ''email'' %> translates > into > > > <input id="user_email" name> "user[email]" size="30" type="text" > value="a@a.com" /> > > Now I want to retrieve the value of the email address. How do I get > the value. I tried different combinations of > > params[''user[email]''] but it''s not working.Use params[:user][:email] instead. Don''t forget to make sure that params[:user] exists. Michael -- Michael Schuerig Most people would rather die than think. mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org In fact, they do. http://www.schuerig.de/michael/ --Bertrand Russell
On Thu, 2005-10-20 at 20:06 -0400, Neeraj Kumar wrote:> I''m following the agile development book by Dave Thomas and group. > > <%= text_field ''user'', ''email'' %> translates into > > <input id="user_email" name> "user[email]" size="30" type="text" > value="a@a.com" /> > > Now I want to retrieve the value of the email address. How do I get the value. I tried different combinations of > > params[''user[email]''] but it''s not working. > > If I use @user = User.new(params[:user]) everything works but I just want the value of email address? >Yeah, you can''t really access values in the hash like that... you might try something like: params[:user][:email] or params[:user][''email''] Cheers, -Robby -- /****************************************************** * Robby Russell, Owner.Developer.Geek * PLANET ARGON, Open Source Solutions & Web Hosting * Portland, Oregon | p: 503.351.4730 | f: 815.642.4068 * www.planetargon.com | www.robbyonrails.com * Programming Rails | www.programmingrails.com *******************************************************/