diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-19 09:38:37 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-01-19 09:39:20 -0800 |
commit | 4c5b73fef8a41bd2bd8435fa4b00f7c40b721650 (patch) | |
tree | e365d2a2478ef3c81baecea85c9aff638509f4ca /activerecord/CHANGELOG.md | |
parent | 00554568e0625b2e4d4212ab7464f02234f74427 (diff) | |
download | rails-4c5b73fef8a41bd2bd8435fa4b00f7c40b721650.tar.gz rails-4c5b73fef8a41bd2bd8435fa4b00f7c40b721650.tar.bz2 rails-4c5b73fef8a41bd2bd8435fa4b00f7c40b721650.zip |
Merge pull request #4531 from exviva/pessimistic_with_lock
Add ActiveRecord::Base#with_lock
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r-- | activerecord/CHANGELOG.md | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 9551987de1..2f78c812c1 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,5 +1,32 @@ ## Rails 3.2.0 (unreleased) ## +* Added a `with_lock` method to ActiveRecord objects, which starts + a transaction, locks the object (pessimistically) and yields to the block. + The method takes one (optional) parameter and passes it to `lock!`. + + Before: + + class Order < ActiveRecord::Base + def cancel! + transaction do + lock! + # ... cancelling logic + end + end + end + + After: + + class Order < ActiveRecord::Base + def cancel! + with_lock do + # ... cancelling logic + end + end + end + + *Olek Janiszewski* + * 'on' and 'ON' boolean columns values are type casted to true *Santiago Pastorino* @@ -10,7 +37,7 @@ Example: rake db:migrate SCOPE=blog - *Piotr Sarnacki* + *Piotr Sarnacki* * Migrations copied from engines are now scoped with engine's name, for example 01_create_posts.blog.rb. *Piotr Sarnacki* |