i'm getting a strange error
on my production install when i try and
create a new user using AL:
ActiveRecord::StatementInvalid: Mysql::Error: Column
'crypted_password' cannot be null: INSERT INTO users
especially strange b/c it works as expected
on my local box.
RUnning
Rails 2.
3.
2 and
ruby 1.8.7
on both boxes.
user.rb:
class User < ActiveRecord::Base
before_create :set_username
acts_as_authentic do |c|
c.require_password_confirmation = false
c.login_field = "email"
c.validates_length_of_password_field_options = {:minimum => 4}
c.validate_login_field = false #don't validate email field with additional validations
end
end
Here's output from my production console:
>> u = User.new
=> #<User id: nil, username: nil, email: nil, crypted_password: nil,
password_salt: nil, persistence_token: nil, single_access_token: nil,
perishable_token: nil, login_count: 0, failed_login_count: 0,
last_request_at: nil, current_login_at: nil, last_login_at: nil,
current_login_ip: nil, last_login_ip: nil, created_at: nil,
updated_at: nil, is_admin: 0, first_name: nil, last_name: nil>
>> u.full_name = 'john smith'
=> "john smith"
>> u.password = 'test'
=> "test"
>> u.email = '
[email protected]'
=> "
[email protected]"
>> u.valid?
=> true
>> u.save
ActiveRecord::StatementInvalid: Mysql::Error: Column
'crypted_password' cannot be null: INSERT INTO `users`
(`single_access_token`, `last_request_at`, `created_at`,
`crypted_password`, `perishable_token`, `updated_at`, `username`,
`failed_login_count`, `current_login_ip`, `password_salt`,
`current_login_at`, `is_admin`, `persistence_token`, `login_count`,
`last_name`, `last_login_ip`, `last_login_at`, `email`, `first_name`)
VALUES('B-XSXwhO7hkbtISIOyEq', NULL, '2009-07-31 01:10:44', NULL,
'FK3mYS2Tp5Tzeq5IXE1z', '2009-07-31 01:10:44', 'john', 0, NULL, NULL,
NULL, 0,
'2c76b645f761eb3509353290e93874cecdb68a63caa165812ab1b126d63660757090ecf69995caef9e78f93d070b524e2542b3fec4ee050726088c2a9fdb0c9f',
0, 'smith', NULL, NULL, '
[email protected]', 'john')
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/connection_adapters/abstract_adapter.rb:212:in `log'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/connection_adapters/mysql_adapter.rb:320:in `execute'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/connection_adapters/abstract/database_statements.rb:
259:in `insert_sql'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/connection_adapters/mysql_adapter.rb:330:in `insert_sql'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/connection_adapters/abstract/database_statements.rb:
44:in `insert_without_query_dirty'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/connection_adapters/abstract/query_cache.rb:18:in
`insert'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/base.rb:2902:in `create_without_timestamps'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/timestamp.rb:29:in `create_without_callbacks'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/callbacks.rb:266:in `create'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/base.rb:2868:in `create_or_update_without_callbacks'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/callbacks.rb:250:in `create_or_update'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/base.rb:2539:in `save_without_validation'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/validations.rb:1009:in `save_without_dirty'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/dirty.rb:79:in `save_without_transactions'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/transactions.rb:229:in `send'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/transactions.rb:229:in
`with_transaction_returning_status'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/connection_adapters/abstract/database_statements.rb:
136:in `transaction'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/transactions.rb:182:in `transaction'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/transactions.rb:228:in
`with_transaction_returning_status'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/transactions.rb:196:in `save'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/transactions.rb:208:in `rollback_active_record_state!'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.
3.2/lib/
active_record/transactions.rb:196:in `save'
No idea why this is happening, and especially why this saves a new user
on dev but not
on production. Any help is much appreciated, thanks!
edit: using Apache & Passenger
2.2.4