activerecord - Ruby on Rails Sql transactions -
i wondering if there better way manage transactions ruby on rails attaching class model ?
student.transaction course.transaction course.enroll(student) student.units += course.units end end i don't want transactions model specific, can begin/commit/rollback them genericly @ controller level no model dependency.
you can use activerecord::base.transaction.
afaik there no difference @ all. opening transaction 1 of models not limit usage of different objects not belonging model within transaction @ all.
see here: http://api.rubyonrails.org/classes/activerecord/transactions/classmethods.html
Comments
Post a Comment