Created
March 31, 2009 15:43
-
-
Save cch1/88236 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb | |
index 7f78191..e55b639 100755 | |
--- a/activerecord/lib/active_record/associations.rb | |
+++ b/activerecord/lib/active_record/associations.rb | |
@@ -1557,7 +1557,8 @@ module ActiveRecord | |
:finder_sql, :counter_sql, | |
:before_add, :after_add, :before_remove, :after_remove, | |
:extend, :readonly, | |
- :validate | |
+ :validate, | |
+ :scope | |
] | |
def create_has_many_reflection(association_id, options, &extension) | |
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb | |
index 1937abd..36ac4de 100644 | |
--- a/activerecord/lib/active_record/reflection.rb | |
+++ b/activerecord/lib/active_record/reflection.rb | |
@@ -148,7 +148,8 @@ module ActiveRecord | |
# a new association object. Use +build_association+ or +create_association+ | |
# instead. This allows plugins to hook into association object creation. | |
def klass | |
- @klass ||= active_record.send(:compute_type, class_name) | |
+ @klass = active_record.send(:compute_type, class_name) | |
+ options[:scope].nil? ? @klass : @klass.send(options[:scope]) | |
end | |
# Returns a new, unsaved instance of the associated class. +options+ will |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment