ActiveRecord and Transactions!
Wednesday, October 29th, 2008If 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 = Post.new(:body=>'Whatever') post.save! end end
This will rollback too if the save fails.
