Model "One"
class One < ActiveRecord::Base
before_save :do_stuff
private
def do_stuff
two = Two.find(8)
two.field2 = 'Value'
two.save!
end
end
Model "Two"
class Two < ActiveRecord::Base
before_save :do_stuff
private
def do_stuff
one = One.find(7)
one.field2 = 'SomeValue'
one.save!
end
end
Executing:
two = Two.find(1)
two.somefield = 'NewVal'
two.save!
Infinite loop will start. What would be most ruby-on-rails way to implement two models that must change each other on before_save callback?