Re: [Rails-core] ActiveRecord and Nested Transactions

68 views
Skip to first unread message

Aaron Patterson

unread,
May 28, 2013, 9:15:17 PM5/28/13
to rubyonra...@googlegroups.com
I don't think the rollback exception should be caught in this case. Can
you write a test for us? It seems both transactions should be rolled
back in the case you've shown below.

On Tue, May 28, 2013 at 11:30:28AM -0700, aya...@gmail.com wrote:
> Googling about 'Nested Transactions' in ActiveRecord brought me to this github
> issue <https://github.com/rails/rails/issues/3455>.
>
> I'm not sure if there are specific semantics around 'nested transactions'
> I'm not familiar with, but I think I'm in the same place as sskirby was
> when he opened the issue.
>
> The ActiveRecord Transactions documentation doesn't explicitly address what
> in my mind would be the baseline behaviour of nested transactions:
>
> User.transaction do
> User.create(:username => 'Kotori')
> User.transaction do
> User.create(:username => 'Nemu')
> raise ActiveRecord::Rollback
> endend
>
>
> Is there any configuration where the nested Rollback *does* indeed cancel
> out itself *and* rollback the parent transaction?
>
> Specifically, we have model classes, model1 and model2 that have their own
> respective save methods. I'd like to combine several of them into a single
> transaction called from say a controller.
>
> Thanks,
> Andy
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Aaron Patterson
http://tenderlovemaking.com/
Reply all
Reply to author
Forward
0 new messages