# How to capture the data entered in a web page in RoR

**URL:** <https://www.ruby-forum.com/t/how-to-capture-the-data-entered-in-a-web-page-in-ror/102002>\
**Category:** Rails\
**Created:** [August 9, 2006, 7:05am UTC](https://www.ruby-forum.com/t/how-to-capture-the-data-entered-in-a-web-page-in-ror/102002 "2006-08-09T07:05:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sathya](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@Sathya](https://www.ruby-forum.com/u/Sathya)\
**Post date:** [August 9, 2006, 7:05am UTC](https://www.ruby-forum.com/t/how-to-capture-the-data-entered-in-a-web-page-in-ror/102002/1 "2006-08-09T07:05:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sathya](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@Sathya](https://www.ruby-forum.com/u/Sathya)\
**Post date:** [August 9, 2006, 8:37am UTC](https://www.ruby-forum.com/t/how-to-capture-the-data-entered-in-a-web-page-in-ror/102002/2 "2006-08-09T08:37:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Sathya](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@Sathya](https://www.ruby-forum.com/u/Sathya)\
**Post date:** [August 15, 2006, 2:11pm UTC](https://www.ruby-forum.com/t/how-to-capture-the-data-entered-in-a-web-page-in-ror/102002/3 "2006-08-15T14:11:48Z")

</div>

> **[Ruby on Rails](https://rubyonrails.org)**
>
> A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

---

<div class="post-metadata">

**Author:** ![Sathya](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c0e974/32.png) [@Sathya](https://www.ruby-forum.com/u/Sathya)\
**Post date:** [August 15, 2006, 2:22pm UTC](https://www.ruby-forum.com/t/how-to-capture-the-data-entered-in-a-web-page-in-ror/102002/4 "2006-08-15T14:22:10Z")

</div>

Indeed these are essentials and you should RTFM.

> From the manual you need to get how to display a form in rails so that it  
> indeed 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
