Hi, iam a newbie to rails , i wanna know how can i capture data entered in a web page by a user For example, to obtain the data entered in a text field in a JSP in Java we write request.getParameter("textfieldname") similarly for any form element, we use this method to get the entered data in the web page Like wise what is the code in Ruby to capture this ? and where should i write this code ? Is it in model or in controller? i am aware that ruby automatically maps the form element names with that of the database columns names and save accordingly, but if i need to display these values before saving them in the database, how can i capture them in the controller before the save method is called? Thanks in Advance Sathya -- Posted via http://www.ruby-forum.com/.
Zack Chandler
2006-Aug-09 06:17 UTC
[Rails] How to capture the data entered in a web page in RoR
Sathya, Use the params array like this: params[:textfieldname] in the controller or view. It is less likely you''d access this in a model. Hope this helps, Zack On 8/8/06, Sathya <sathya.kishore@lgcnsglobal.com> wrote:> > Hi, iam a newbie to rails , i wanna know how can i capture data entered > in a web page by a user > > For example, to obtain the data entered in a text field in a JSP in > Java we write request.getParameter("textfieldname") > similarly for any form element, we use this method to get the entered > data in the web page > > Like wise what is the code in Ruby to capture this ? and where should i > write this code ? Is it in model or in controller? > > i am aware that ruby automatically maps the form element names with that > of the database columns names and save accordingly, but if i need to > display these values > before saving them in the database, how can i capture them in the > controller before the save method is called? > > Thanks in Advance > > Sathya > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
David Mitchell
2006-Aug-09 06:19 UTC
[Rails] How to capture the data entered in a web page in RoR
http://www.rubyonrails.org/docs On 09/08/06, Sathya <sathya.kishore@lgcnsglobal.com> wrote:> > Hi, iam a newbie to rails , i wanna know how can i capture data entered > in a web page by a user > > For example, to obtain the data entered in a text field in a JSP in > Java we write request.getParameter("textfieldname") > similarly for any form element, we use this method to get the entered > data in the web page > > Like wise what is the code in Ruby to capture this ? and where should i > write this code ? Is it in model or in controller? > > i am aware that ruby automatically maps the form element names with that > of the database columns names and save accordingly, but if i need to > display these values > before saving them in the database, how can i capture them in the > controller before the save method is called? > > Thanks in Advance > > Sathya > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Jan Prill
2006-Aug-09 08:24 UTC
[Rails] How to capture the data entered in a web page in RoR
Indeed these are essentials and you should RTFM.>From the manual you need to get how to display a form in rails so that itindeed gets mapped to the AR-Model. Let''s say you''ve got an input form for a User. Then, if you made up the form according to the rails convention you are able to get a hash of the input by using params[:user] in the controller. Rails is so well documented - at first you might have a look at the videos - that you shouldn''t have any problems, especially when you were into web development with java. Cheers, Jan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060809/63d9ce16/attachment.html