I have the following model
class User < ActiveRecord::Base
VALID_EMAIL_REGEX = /^.+@.+\..+$/i
attr_accessible :active_list_id, :password, :password_confirmation, :email, :temp
has_secure_password
before_create { generate_token(:auth_token) }
if :temp.nil?
before_validation :downcase_email
validates_presence_of :email, :password, :password_confirmation, :on => :create
validates_confirmation_of :password
#[email protected]
validates :email, :uniqueness => true,
:format => {:with => VALID_EMAIL_REGEX }
end
after_create { make_list([email,"'s shopping list"].join('')) }
has_many :shopping_lists
has_many :transactions, :class_name => 'Order'
HUMANIZED_ATTRIBUTES = {
:password_digest => "Password"
}
...
end
I try to create a model in my rails console by calling User.create(:temp => true) (which is a boolean and is defined in my migrations/schema). But it always rollsback the transaction. What am I doing wrong?
I also tried doing :if => temp.nil? and if => "temp.nil?" and :if => lambda { |user| user.temp.nil? } for all 3 of my validations.