diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-06 10:18:51 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-06 10:18:51 +0000 |
commit | 390e6d246ceb76ead8dbcf7b87591f51fc316082 (patch) | |
tree | b8d0e8315472916e90cd74fe26c8e180ba4841cc /activerecord/lib/active_record/associations | |
parent | 6c5572701aa74c90dc5ee3282f450c1a17207c36 (diff) | |
download | rails-390e6d246ceb76ead8dbcf7b87591f51fc316082.tar.gz rails-390e6d246ceb76ead8dbcf7b87591f51fc316082.tar.bz2 rails-390e6d246ceb76ead8dbcf7b87591f51fc316082.zip |
r2915@asus: jeremy | 2005-11-06 05:02:53 -0800
Rename Base.constrain to Base.with_scope so it doesn't conflict with existing concept of database constraints. Make scoping more robust: uniform method => parameters, validated method names and supported finder parameters, raise exception on nested scopes.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2888 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_association.rb | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb index 2972aa0248..a90d89a69b 100644 --- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb @@ -80,7 +80,7 @@ module ActiveRecord if @target.respond_to?(method) || (!@association_class.respond_to?(method) && Class.respond_to?(method)) super else - @association_class.constrain(:conditions => @finder_sql, :joins => @join_sql, :readonly => false) do + @association_class.with_scope(:find => { :conditions => @finder_sql, :joins => @join_sql, :readonly => false }) do @association_class.send(method, *args, &block) end end diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index b04cb81a5c..9ee06ffbcb 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -89,11 +89,16 @@ module ActiveRecord if @target.respond_to?(method) || (!@association_class.respond_to?(method) && Class.respond_to?(method)) super else - @association_class.constrain( + @association_class.with_scope( + :find => { :conditions => @finder_sql, :joins => @join_sql, - :readonly => false, - :creation => { @association_class_primary_key_name => @owner.id }) do + :readonly => false + }, + :create => { + @association_class_primary_key_name => @owner.id + } + ) do @association_class.send(method, *args, &block) end end |