Savings records that fail validation.
Tuesday, June 9th, 2009 By: DanielSo I had this problem with a record that was being saved even though it failed validation:
cc = CreditCard.new(:card_number => 'invalid') >> cc.save => false >> cc.id => 3
That one had me stumped for a while until I realized I was carelessly using update_attribute in my custom writer:
def card_number=(num) update_attribute(:crypted_card_number, encrypt(num)) end
And we all know that update_attribute “saves the record without going through the normal validation procedure.”
Everything worked much nicer after I changed the code to:
def card_number=(num) self.crypted_card_number = encrypt(num) end

Moki Systems is seeking a full-time Ruby on Rails developer. The person should be a self starter, willing and able to figure things out on their own. Applicant should have experience with Ruby on Rails, MVC programming concepts, MySQL and/or PostgreSQL experience and the ability to learn new technologies. Any additional...