ActiveRecord and Transactions!

If you ever have to do multiple actions with activerecord, you should group it into a transaction like so:

Post.transaction do
  posts.each do |post|
    post =>'Whatever')!

This will rollback too if the save fails.

Leave a Reply

Your email address will not be published. Required fields are marked *