# Form field without column in DB

**URL:** <https://www.ruby-forum.com/t/form-field-without-column-in-db/124256>\
**Category:** Rails\
**Created:** [December 27, 2007, 4:42am UTC](https://www.ruby-forum.com/t/form-field-without-column-in-db/124256 "2007-12-27T04:42:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 27, 2007, 4:42am UTC](https://www.ruby-forum.com/t/form-field-without-column-in-db/124256/1 "2007-12-27T04:42:40Z")

</div>

I’m using authenticated gem and adding turing to it… I’d like to  
pass a form variable back to the controller. but there is no need to  
keep it in the DB. the form renders fine the initial time. but fails  
if it fails when the controller tries to display the form with data  
when the user gives bad input… password and password confirm don;t  
match. should i just add the field to the db or is there a better  
way?

last newbie question for tonight!! Thanks for all the help!

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 27, 2007, 8:38am UTC](https://www.ruby-forum.com/t/form-field-without-column-in-db/124256/2 "2007-12-27T08:38:47Z")

</div>

spokra wrote:

> I’m using authenticated gem and adding turing to it… I’d like to  
> pass a form variable back to the controller. but there is no need to  
> keep it in the DB. the form renders fine the initial time. but fails  
> if it fails when the controller tries to display the form with data  
> when the user gives bad input… password and password confirm don;t  
> match. should i just add the field to the db or is there a better  
> way?
> 
> last newbie question for tonight!! Thanks for all the help!

No need to add that field to the db.

The password field can be given as:  
password\_field :password  
and the password confirmation field given as:  
password\_field :password\_confirmation  
and add a validation in the model as validates\_confirmation\_of :password

There will be only ‘password’ field in the db.

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 27, 2007, 5:00pm UTC](https://www.ruby-forum.com/t/form-field-without-column-in-db/124256/3 "2007-12-27T17:00:51Z")

</div>

ok I put turing=session[‘turning’] in my controller, added a  
turing\_confirmation field to the view and the  
validates\_confirmation\_of :turning to the model.

now i get the folling error!  
undefined method `turing’ for #Accounts:0xa6fef0c8

I assume that this is being caused because AR is thinking that it  
should be putting turing into a column of the DB. how do I tell AR  
that it shouldn;t do that?

turing and turing\_confirmation are not in the DB they are just there  
to perform Captcha on the creation of the account.

On Dec 26, 11:38 pm, Vidya Ramachandren \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 27, 2007, 3:17pm UTC](https://www.ruby-forum.com/t/form-field-without-column-in-db/124256/4 "2007-12-27T15:17:56Z")

</div>

so if i have a session variable session[‘turing’] and submit  
turing\_confirmation will the

validates\_confirmation\_of :turing

catch it? or will i have to get the session variable into a local  
variable some how? my guess would be to put :turing=session[‘turing’]  
in the controller…

and i take it i will have to add :turing to the list in.

attr\_accessible :login, :email, :password, :password\_confirmation,  
:turing\_configure

On Dec 26, 11:38 pm, Vidya Ramachandren \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 27, 2007, 6:17pm UTC](https://www.ruby-forum.com/t/form-field-without-column-in-db/124256/5 "2007-12-27T18:17:47Z")

</div>

The Account model needs a setter method in order to have the turing  
value assigned to it, which it sounds like you’ve done.  
How are you assigning the values to the model object, in the controller?

Doug

On Dec 27, 2007, at 11:56 AM, spokra wrote:

> Am i going down the wrong path here?
> 
> > validates\_confirmation\_of :turning to the model.
> > 
> > > > fails  
> > > > password\_field :password

Doug Pfeffer  
Developer,  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 27, 2007, 6:26pm UTC](https://www.ruby-forum.com/t/form-field-without-column-in-db/124256/6 "2007-12-27T18:26:43Z")

</div>

well i just tried

params[:accounts] = {:turing =\> session[‘turing’]}

which whipes out all the other values in the hash… I got the  
ruby\_debugger installed and now can view the application while its  
running.

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 27, 2007, 6:13pm UTC](https://www.ruby-forum.com/t/form-field-without-column-in-db/124256/7 "2007-12-27T18:13:40Z")

</div>

Hmmm adding a method of turing in the model got rid of the error!!

but the validate is not working. I stuffed the session variable  
turing into the params like this in the controller

params[:turing] = session[‘turing’]

My thinking is AR knows how to find the submited form… so i would add  
it from the controller…  
Am i going down the wrong path here?

I’m a carpy programmer if i was in php I would just output both  
turing and turing\_confirmation in a debug statement in my code… other  
then learning how to use the debugger how can a verify that I’m  
getting the variables set correctly?

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 28, 2007, 1:12am UTC](https://www.ruby-forum.com/t/form-field-without-column-in-db/124256/8 "2007-12-28T01:12:52Z")

</div>

Um, why are you adding all of those attr\_accessors? So you get access to  
the  
login field in the database? You do not need to do this! ActiveRecord  
does  
it for you!

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [December 28, 2007, 3:16am UTC](https://www.ruby-forum.com/t/form-field-without-column-in-db/124256/9 "2007-12-28T03:16:50Z")

</div>

no I’m not trying to get the turing to the db… the text of the  
turing in in a session variable. and the form returns the users  
confirmation of the turing image. I just want to use active records  
to verify the two…
