Rails: Data not getting saved with assign_attributes in before save

Viewed 379

I am doing an update in before_save as below:

has_many :things

before_save :set_things

def set_things
  things = all_things.map do |t|
    t.assign_attributes(attrs) 
    t
  end
  self.things = things
end

When i save the object as t.save! , the objects has updated attributes, but once reloaded its going back to old value, so updation is not persisting. If i use, t.update_attributes it is working fine, but isnt assign_attributes supposed to persist on save? Why isnt it working ?

1 Answers
Related