The problem with the current system is that
@item = Item.new
begin
transaction do
@item.save
raise
end
rescue
end
@item.new_record? == false
I think the syntax for your raise way would be better to keep a system
like in edge where rollback! and rollback act differently
transaction do |c|
c.rollback!
puts 'this doesnt happen'
end
transaction do |c|
c.rollback
puts 'carries on'
end
easy to add on the current system too.....
I've been having fix-off today... [PATCH] that fixes the first problem
I mentioned ... though that did involve some magic :)
http://dev.rubyonrails.org/ticket/7658
would love some feedback on the ideas.
cheers
farms.
On Feb 27, 12:57 am, "Michael Koziarski" <[EMAIL PROTECTED]>
wrote:
> > I think it's this slight confusion that worries me.... if it could
> > have two possible interpretations, then I would hope that the less
> > dangerous one would be implemented?
>
> > I'd certainly prefer to find out that the reason my model wasn't being
> > destroyed was that I can't COMMIT a transaction with a 'return', than
> > to discover that my data is going missing because I was using break to
> > drop outs of a transaction early?
>
> It's way too risky for rails to try and guess what your intentions
> are. That way lies madness
>
> You can do this at present by raising an exception to roll back the
> transaction, but you then have to rescue it
>
> so at present you have to do
>
> begin
> transaction do
> @item.save
> raise SomethingError.new
> end
> rescue SomethingError=>se
> end
>
> if we could simplify that to
>
> transaction do
> @item.save
> raise ActiveRecord::RollbackTransaction.new
> end
>
> Life would be much easier for all concerned
>
> Alternatively in edge you can currently rollback the transaction explicitly.
>
> http://dev.rubyonrails.org/changeset/6196
>
> That API isn't necessarily the final one, but it would certainly be
> nice to have an exception you can raise to roll back the transaction
> without necessarily having to rescue it explicitly.
>
> --
> Cheers
>
> Koz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---