# Passing variables from view to controller(s)

**URL:** <https://www.ruby-forum.com/t/passing-variables-from-view-to-controller-s/48132>\
**Category:** Rails\
**Created:** [November 15, 2005, 6:22am UTC](https://www.ruby-forum.com/t/passing-variables-from-view-to-controller-s/48132 "2005-11-15T06:22:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yehweh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ba9def/32.png) [@yehweh](https://www.ruby-forum.com/u/yehweh)\
**Post date:** [November 15, 2005, 6:22am UTC](https://www.ruby-forum.com/t/passing-variables-from-view-to-controller-s/48132/1 "2005-11-15T06:22:48Z")

</div>

One more from a noob 🙂

Hi everyone,

I’m trying to pass two variables from the view (user entered data).  
Compare one field with a database entry, if same the second field should  
be saved in the database. :This is to let the user update his password:  
I know it can be done but the have no idea how to ☹ . Any help will be  
greatly appreciated.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![yehweh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ba9def/32.png) [@yehweh](https://www.ruby-forum.com/u/yehweh)\
**Post date:** [November 15, 2005, 6:42am UTC](https://www.ruby-forum.com/t/passing-variables-from-view-to-controller-s/48132/2 "2005-11-15T06:42:36Z")

</div>

Hu Sushruth,

You shouldn’t need to pass variables from the view exactly, the  
information is posted back to the controller and ends up in the @params  
hash. However, I suggest you take a look at the code for the Login  
generator. Try running this generator on a blank rails site, and you’ll  
be able to go over the code. It’s very simple (compared to the more  
robust salted hash version, or the login engine), and does exactly what  
you’re suggesting.

Craig

---

<div class="post-metadata">

**Author:** ![yehweh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ba9def/32.png) [@yehweh](https://www.ruby-forum.com/u/yehweh)\
**Post date:** [November 15, 2005, 7:16am UTC](https://www.ruby-forum.com/t/passing-variables-from-view-to-controller-s/48132/3 "2005-11-15T07:16:28Z")

</div>

craig wrote:

> Hu Sushruth,
> 
> You shouldn’t need to pass variables from the view exactly, the  
> information is posted back to the controller and ends up in the @params  
> hash. However, I suggest you take a look at the code for the Login  
> generator. Try running this generator on a blank rails site, and you’ll  
> be able to go over the code. It’s very simple (compared to the more  
> robust salted hash version, or the login engine), and does exactly what  
> you’re suggesting.
> 
> Craig

Hey thanks Craig, I will try to use the login generator for now. I  
really wanted to develop the whole thing on my own (I know its like  
reinventing the wheel, so that i get a better understanding of the whole  
thing. Thanks again.

---

<div class="post-metadata">

**Author:** ![yehweh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/ba9def/32.png) [@yehweh](https://www.ruby-forum.com/u/yehweh)\
**Post date:** [November 15, 2005, 12:20pm UTC](https://www.ruby-forum.com/t/passing-variables-from-view-to-controller-s/48132/4 "2005-11-15T12:20:10Z")

</div>

Look at the code one of the generators produces, get a grip on what  
it’s doing, and then see if you can re-write it in your own app. Use  
it as a reference. Once you’ve done that, you’ll have a much better  
footing for using the techniques you’ve seen to build your own  
customised system. You’ll see whaht works for you, and which bits you  
think are crap - and hopefully have better ideas to replace them!

- james
