There is model Ratification with attribute comment (of type text)
def Ratification < ActiveRecord::Base
attr_accessor :add_comment
def add_comment=(text)
self.comment ||= ""
self.comment << "\r\n" + text
end
end
And if I use add_comment= it is ok before I save the object. After save comment changes was dropped.
>> r = Ratification.last
Ratification Load (0.6ms) SELECT * FROM `ratifications` ORDER BY ratifications.id DESC LIMIT 1
=> #<Ratification id: 8, user_id: 686, comment: "dasads", created_at: "2010-06-25 13:16:24", updated_at: "2010-06-25 13:38:36">
>> r.comment
=> "dasads"
>> r.add_comment="text"
=> "text"
>> r.comment
=> "dasads\r\ntext"
>> r.save
SQL (0.7ms) BEGIN
SQL (0.2ms) COMMIT
=> true
>> r.reload
Ratification Load (1.6ms) SELECT * FROM `ratifications` WHERE (`ratifications`.`id` = 8)
=> #<Ratification id: 8, user_id: 686, comment: "dasads", created_at: "2010-06-25 13:16:24", updated_at: "2010-06-25 13:38:36">
>> r.comment
=> "dasads"
Why?!
Rails 2.3.8 Ruby 1.8