class Referral < ActiveRecord::Base
belongs_to :user
validates :comment, :presence => true
end
Loading development environment (Rails 3.1.1.rc1)
001:0> r = Referral.first
Referral Load (0.6ms) SELECT "referrals".* FROM "referrals" LIMIT 1
=> #<Referral id: 3, user_id: 2, comment: "developer", created_at: "2011-10-11 10:56:14", updated_at: "2011-10-11 10:56:14">
002:0> r.update_attributes(:comment => nil)
(0.4ms) BEGIN
(0.3ms) ROLLBACK
=> false # FAILED (because of validation)
003:0> r.errors.messages
=> {:comment=>["can't be blank"]} # this is the validation that fails
004:0> r.update_attribute(:comment, nil)
(0.4ms) BEGIN
(1.0ms) UPDATE "referrals" SET "comment" = NULL, "updated_at" = '2011-10-16 15:43:22.544048' WHERE "referrals"."id" = 3
(1.3ms) COMMIT
=> true # the save succeeded, without checking the validation
005:0> r
=> #<Referral id: 3, user_id: 2, comment: nil, created_at: "2011-10-11 10:56:14", updated_at: "2011-10-16 15:43:22">