This project is archived and is in readonly mode.
Rails does not save concatataned string attributes
-
Ravil Bayramgalin
- Tag set to invalid
ActiveRecord uses partial updates. It means that only changed (dirty) attributes will be updated. To keep track of dirty attributes ActiveRecord checks on assignment if new value is equal to old one if not attribute will be marked as dirty.
In your example,
str = (r.description << "oink")you changed description attribute in place without assignment, so later on when you do make an assignment
r.description = strdescription already equals str, so it's not marked as changed hence this attribute is not updated on save.
If you really need to use in place operation then you should mention it beforehand
r.description_will_change! r.description << 'oink' r.save # works as intended -
Rizwan Reza
- State changed from new to wontfix
- Importance changed from to Low
-
Rizwan Reza
- Tag cleared.