I ran into a quirk. I have a GuardianUpdate model with a "read" field that is logical. When I go to call update_attribute (: read, true) on a record, the rails cannot actually update the record.
Here is my console output:
1.9.3p0 :026 > g = GuardianUpdate.find(1)
GuardianUpdate Load (0.7ms) SELECT `guardian_updates`.* FROM `guardian_updates` WHERE `guardian_updates`.`id` = 1 LIMIT 1
=> #<GuardianUpdate id: 1, update_id: 2, guardian_id: 11, read: true, created_at: "2012-04-21 04:06:45", updated_at: "2012-04-21 04:06:45">
1.9.3p0 :027 > g.update_attribute(:read, false)
(0.3ms) BEGIN
Update Load (0.4ms) SELECT `updates`.* FROM `updates` WHERE `updates`.`id` = 2 LIMIT 1
(0.1ms) COMMIT
=> true
1.9.3p0 :028 > g.reload
GuardianUpdate Load (0.5ms) SELECT `guardian_updates`.* FROM `guardian_updates` WHERE `guardian_updates`.`id` = 1 LIMIT 1
=> #<GuardianUpdate id: 1, update_id: 2, guardian_id: 11, read: true, created_at: "2012-04-21 04:06:45", updated_at: "2012-04-21 04:06:45">
1.9.3p0 :029 >
As you can tell, there are no UPDATE sql statements. Here is my GuaridanUpdate model:
class GuardianUpdate < ActiveRecord::Base
belongs_to :update
belongs_to :guardian
end
Any thoughts?
I should mention that update_column (: read, true) works, no problem.
source
share