Here's the code:
class Operation < ActiveRecord::Base
belongs_to :service
has_many :errors, :dependent => :destroy
attr_accessible :name, :disabled, :timeout
validates_uniqueness_of :name, :scope => :service_id
def to_s
self.name
end
end
class Error < ActiveRecord::Base
belongs_to :operation
has_many :errors, :through => :operation # here's the funny mistake
end
So when I call @operation.update_attributes it destroys all errors associated with operation. The question is - why?!