Forum: Ruby on Rails How to do a rollback

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Christian G. < (Guest)
on 2005-11-30 22:54
Hi. I'd like to know how can i do a rollback after a
Table.new(params:id)?

thank you
phurley (Guest)
on 2005-12-01 17:37
(Received via mailing list)
On 11/30/05, Christian G. <removed_email_address@domain.invalid>
<removed_email_address@domain.invalid> wrote:
> Hi. I'd like to know how can i do a rollback after a
> Table.new(params:id)?

You need to put it into a transaction:

Table.transaction do

  Table.new(....)
  #  more stuff

  # if you leave the block via an exception, the transaction is
  # rolled back, if you leave it normally it is committed....
end
Ruby R. (Guest)
on 2006-06-13 08:59
Thanks christian!
It worked like charm!
This topic is locked and can not be replied to.