diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-08-13 16:37:44 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-08-13 16:54:05 +0100 |
commit | 24f902b1bcfa5dca4bfc7f2b978a4b0dece73894 (patch) | |
tree | 97f3ce1357170746f7ecd22f2dd9630408468d05 /activerecord/test/models | |
parent | 291072a64a2b191816f395b25aae4a50d2dcfe16 (diff) | |
download | rails-24f902b1bcfa5dca4bfc7f2b978a4b0dece73894.tar.gz rails-24f902b1bcfa5dca4bfc7f2b978a4b0dece73894.tar.bz2 rails-24f902b1bcfa5dca4bfc7f2b978a4b0dece73894.zip |
Fix default scope thread safety. Thanks @thedarkone for reporting.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/developer.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/models/developer.rb b/activerecord/test/models/developer.rb index f182a7fa97..4dc9fff9fd 100644 --- a/activerecord/test/models/developer.rb +++ b/activerecord/test/models/developer.rb @@ -227,3 +227,12 @@ class EagerDeveloperWithCallableDefaultScope < ActiveRecord::Base default_scope OpenStruct.new(:call => includes(:projects)) end + +class ThreadsafeDeveloper < ActiveRecord::Base + self.table_name = 'developers' + + def self.default_scope + sleep 0.05 if Thread.current[:long_default_scope] + limit(1) + end +end |