Answer the question
In order to leave comments, you need to log in
How in Ruby on Rails to rollback an add if its related ones fail?
For example, there are Subscriber and Address models and they are interconnected, that is, Subscriber is added first, and then Address is added with the Subscriber id saved.
That is something like this, in the controller:
def create
subs = Subscriber.create(...)
Address.create(subscriber_id: subs.id...)
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question