I have this loop
pages.each{|page| page.update_attribute(:sort_order, self.sort_order.to_i + 1)}
I used update_attribute to skip the before_update or before_save was not being called
before_save :set_data
before_update :set_data
but the set_data is being called again….any ideas on how to avoid this
I even tried the following
pages.each do |page|
page.sort_order = self.sort_order.to_i + 1
page.save(:validate => false)
end
I am trying to update and the later pages to a sort_order + 1 so I can have the pages in some order
Any ideas
The docs say that
#update_attribute()and#save()invoke callbacks.I had the same issue a few months ago and I don’t think you can save a record without the callbacks being invoked.
Edit
I just saw
#update_column()in the docs, which skips callbacks.