I’m pretty new in RoR. I have to deal with 2 different objects from
the model, and to do some updates on them… How can I work in an
transactional scope? I mean, if second fails, the first rolls back.
Where do I have to put this code? In the controller, in the model, or
is there any kind of service layer?
Broadly speaking, this is a business decision so it belongs where the
BL resides – in the model layer. Depending on how your models are
related, some of that may be taken care of for you through the
association proxies. For example, if Header has_many :details (Detail
belongs_to :header) then…