# Restful\_authentication: Why are columns I add to user table never populated?

**URL:** <https://www.ruby-forum.com/t/restful-authentication-why-are-columns-i-add-to-user-table-never-populated/126837>\
**Category:** Rails\
**Created:** [January 22, 2008, 5:52pm UTC](https://www.ruby-forum.com/t/restful-authentication-why-are-columns-i-add-to-user-table-never-populated/126837 "2008-01-22T17:52:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 22, 2008, 5:52pm UTC](https://www.ruby-forum.com/t/restful-authentication-why-are-columns-i-add-to-user-table-never-populated/126837/1 "2008-01-22T17:52:50Z")

</div>

Hi,

I’m using the restful\_authentication plugin that I downloaded from  
here – [http://agilewebdevelopment.com/plugins/](http://agilewebdevelopment.com/plugins/). I wanted to use the  
plugin with an existing table I have, which has a column named  
“user\_type\_id”. However, when I submit the form, although the columns  
the plugin is expecting get populated, none of the ones I have  
supplied do. Here is my form:

\<%= start\_form\_tag(:action =\> “userconfirm”) %\>

\<%= hidden\_field ‘user’, ‘user\_type\_id’, :value=\>2 %\>

First name  
\<%= text\_field 'user', 'ship\_to\_first\_name' %\>

...

Username  
\<%= text\_field 'user', 'login' %\>

Password  
\<%= password\_field 'user', 'password' %\>

Confirm Password  
\<%= password\_field 'user', 'password\_confirmation' %\>

 \<%= submit\_tag "Create" %\> \<% end\_form\_tag %\>

and here is the section defined in the controller.

```
    def userconfirm
            @user = User.new(params[:user])
            if @user.save
                    flash[:notice] = 'User was successfully

```

created.’  
redirect\_to :action =\> ‘list’  
else  
render :action =\> ‘userinfo’  
end  
end

The error I get is  
ActiveRecord::StatementInvalid in RegisterController#userconfirm

Mysql::Error: #23000Column ‘user\_type\_id’ cannot be null: INSERT INTO  
users (`created_on`, `last_login`, `pharmacy_id`, `provincial_tax`,  
`salt`, `tax`, `work_phone`, `work_phone_extension`, `cc_company`,  
`cc_number`, `discount`, `ship_to_city`, `ship_to_last_name`,  
`user_type_id`, `cc_security_code`, `comments`, `company_name`,  
`crypted_password`, `bill_to_attn`, `bill_to_country`,  
`bill_to_street2`, `demo`, `ship_to_country`, `updated_on`,  
`activation_code`, `dateofbirth`, `html_email_pref`,  
`lock_order_form_prices`, `ship_to_street`, `ship_to_zip`,  
`show_retail_prices`, `user_group_id`, `bill_to_city`, `enabled`,  
`bill_to_company`, `user_agent`, `fax`, `phone`, `ship_to_attn`,  
`ship_to_street2`, `shipping`, `bill_to_last_name`, `bill_to_street`,  
`cc_exp_date`, `reseller_id`, `user_id`, `bill_to_state`, `login`,  
`ship_to_first_name`, `ship_to_state`, `bill_to_first_name`,  
`bill_to_zip`, `email`, `po_num`, `ship_to_company`)  
VALUES(‘2008-01-22 09:03:30’, NULL, NULL,  
0.0, ‘deb98c56f0a3f750c9d66869903ef573be1774f5’, 0.0, NULL, NULL,  
NULL, NULL, 0.0, NULL, NULL, NULL, NULL, NULL, ‘’,  
‘5e9f6eb74cbb331641afe002ecce8f5f612d358b’, NULL, NULL, NULL, 0, NULL,  
‘2008-01-22 09:03:30’, ‘399806887d510ca24311133ca86775d9946f3644’,  
NULL, 1, 0, NULL, NULL, 1, NULL, NULL, 1, NULL, NULL, NULL, NULL,  
NULL, NULL,  
0.0, NULL, NULL, NULL, NULL, NULL, NULL, ‘laredo223’, NULL, NULL,  
NULL, NULL, ‘removed\_email\_address@domain.invalid’, NULL, NULL)

RAILS\_ROOT: ./script/…/config/…  
Application Trace | Framework Trace | Full Trace

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/  
active\_record/connection\_adapters/abstract\_adapter.rb:128:in `log' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/connection_adapters/mysql_adapter.rb:243:in `execute’

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/  
active\_record/connection\_adapters/mysql\_adapter.rb:253:in `insert' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/base.rb:1814:in `create\_without\_callbacks’

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/  
active\_record/callbacks.rb:254:in `create_without_timestamps' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/timestamp.rb:30:in `create’

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/  
active\_record/base.rb:1792:in `create_or_update_without_callbacks' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/callbacks.rb:242:in `create\_or\_update’

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/  
active\_record/base.rb:1548:in `save_without_validation' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/validations.rb:752:in `save\_without\_transactions’

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/  
active\_record/transactions.rb:129:in `save' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/connection_adapters/abstract/database_statements.rb: 59:in `transaction’

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/  
active\_record/transactions.rb:95:in `transaction' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/ active_record/transactions.rb:121:in `transaction’

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/  
active\_record/transactions.rb:129:in `save' /usr/local/apache2/htdocs/easyrx/app/controllers/ register_controller.rb:59:in `userconfirm’

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 22, 2008, 6:42pm UTC](https://www.ruby-forum.com/t/restful-authentication-why-are-columns-i-add-to-user-table-never-populated/126837/2 "2008-01-22T18:42:44Z")

</div>

Hi,

Did you add your custom column to the list of columns listed after

attr\_accessible?

attr\_accessible :user\_type\_id, :email, :login, :password,  
:password\_confirmation

something like that

Binh

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 23, 2008, 1:01am UTC](https://www.ruby-forum.com/t/restful-authentication-why-are-columns-i-add-to-user-table-never-populated/126837/3 "2008-01-23T01:01:52Z")

</div>

is :user\_type\_id set in attr\_protected?

On Jan 23, 2008 3:21 AM, removed\_email\_address@domain.invalid \<  
removed\_email\_address@domain.invalid\> wrote:

> \<%= start\_form\_tag(:action =\> “userconfirm”) %\>  
> \<%= password\_field ‘user’, ‘password’ %\>
> 
>   
> if @user.save  
> ActiveRecord::StatementInvalid in RegisterController#userconfirm  
> `show_retail_prices`, `user_group_id`, `bill_to_city`, `enabled`,  
> NULL, 1, 0, NULL, NULL, 1, NULL, NULL, 1, NULL, NULL, NULL, NULL,  
> active\_record/connection\_adapters/mysql\_adapter.rb:243:in `execute’
> 
> /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/  
> /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/  
> active\_record/transactions.rb:129:in `save' /usr/local/apache2/htdocs/easyrx/app/controllers/ register_controller.rb:59:in `userconfirm’
> 
> >

–  
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:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 23, 2008, 1:58am UTC](https://www.ruby-forum.com/t/restful-authentication-why-are-columns-i-add-to-user-table-never-populated/126837/4 "2008-01-23T01:58:02Z")

</div>

Yup that was it. I added it to attr\_accessible and the user was  
created. Thanks for the help. 5 stars. - Dave
