Saving a record in Authlogic table
- by denniss
I am using authlogic to do my authentication. The current model that serves as the authentication model is the user model. I want to add a "belongs to" relationship to user which means that I need a foreign key in the user table. Say the foreign key is called car_id in the user's model. However, for some reason, when I do
u = User.find(1)
u.car_id = 1
u.save!
I get
ActiveRecord::RecordInvalid: Validation failed: Password can't be blank
My guess is that this has something to do with authlogic. I do not have validation on password on the user's model. This is the migration for the user's table.
def self.up
create_table :users do |t|
t.string :email
t.string :first_name
t.string :last_name
t.string :crypted_password
t.string :password_salt
t.string :persistence_token
t.string :single_access_token
t.string :perishable_token
t.integer :login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
t.integer :failed_login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
t.datetime :last_request_at # optional, see Authlogic::Session::MagicColumns
t.datetime :current_login_at # optional, see Authlogic::Session::MagicColumns
t.datetime :last_login_at # optional, see Authlogic::Session::MagicColumns
t.string :current_login_ip # optional, see Authlogic::Session::MagicColumns
t.string :last_login_ip # optional, see Authlogic::Session::MagicColumns
t.timestamps
end
end
And later I added the car_id column to it.
def self.up
add_column :users, :user_id, :integer
end
Is there anyway for me to turn off this validation?