laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Jan-22 16:51 UTC
restful_authentication: Why are columns I add to user table never populated?
Hi, I''m using the restful_authentication plugin that I downloaded from here -- 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") %> <!--[form:user]--> <%= hidden_field ''user'', ''user_type_id'', :value=>2 %> <p><label for="user_ship_to_first_name">First name</label><br/> <%= text_field ''user'', ''ship_to_first_name'' %></p> ... <p><label for="user_login">Username</label><br/> <%= text_field ''user'', ''login'' %></p> <p><label for="user_password">Password</label><br/> <%= password_field ''user'', ''password'' %></p> <p><label for="password_confirmation">Confirm Password</label><br/> <%= password_field ''user'', ''password_confirmation'' %></p> <%= 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, ''laredotornado-KOeF8Pz0L3c@public.gmane.org'', 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'' --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Binh Ly
2008-Jan-22 17:42 UTC
Re: restful_authentication: Why are columns I add to user ta
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg
2008-Jan-22 23:51 UTC
Re: restful_authentication: Why are columns I add to user table never populated?
is :user_type_id set in attr_protected? On Jan 23, 2008 3:21 AM, laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org < laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org> wrote:> > Hi, > > I''m using the restful_authentication plugin that I downloaded from > here -- 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") %> > <!--[form:user]--> > <%= hidden_field ''user'', ''user_type_id'', :value=>2 %> > > <p><label for="user_ship_to_first_name">First name</label><br/> > <%= text_field ''user'', ''ship_to_first_name'' %></p> > ... > <p><label for="user_login">Username</label><br/> > <%= text_field ''user'', ''login'' %></p> > > <p><label for="user_password">Password</label><br/> > <%= password_field ''user'', ''password'' %></p> > > <p><label for="password_confirmation">Confirm Password</label><br/> > <%= password_field ''user'', ''password_confirmation'' %></p> > <%= 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, ''laredotornado-KOeF8Pz0L3c@public.gmane.org'', 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'' > > > > > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Jan-23 00:56 UTC
Re: restful_authentication: Why are columns I add to user table never populated?
Yup that was it. I added it to attr_accessible and the user was created. Thanks for the help. 5 stars. - Dave On Jan 22, 5:51 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> is :user_type_id set in attr_protected? > > On Jan 23, 2008 3:21 AM, laredotorn...-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org < > > > > > > laredotorn...-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org> wrote: > > > Hi, > > > I''m using the restful_authentication plugin that I downloaded from > > here --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") %> > > <!--[form:user]--> > > <%= hidden_field ''user'', ''user_type_id'', :value=>2 %> > > > <p><label for="user_ship_to_first_name">First name</label><br/> > > <%= text_field ''user'', ''ship_to_first_name'' %></p> > > ... > > <p><label for="user_login">Username</label><br/> > > <%= text_field ''user'', ''login'' %></p> > > > <p><label for="user_password">Password</label><br/> > > <%= password_field ''user'', ''password'' %></p> > > > <p><label for="password_confirmation">Confirm Password</label><br/> > > <%= password_field ''user'', ''password_confirmation'' %></p> > > <%= 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, ''laredotorn...-KOeF8Pz0L3c@public.gmane.org'', 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'' > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---