aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-12-27 00:21:24 +0530
committerPratik Naik <pratiknaik@gmail.com>2009-12-27 00:25:00 +0530
commit83f24afd44ecd6fb6e38d5e8a6830dfca4bf5ffe (patch)
treea3908cde2eff6504b9635af2bb14ed02c185049e /activerecord/lib/active_record/associations
parentf3741506981d8d4aafb28066f5a3a0509a4da846 (diff)
downloadrails-83f24afd44ecd6fb6e38d5e8a6830dfca4bf5ffe.tar.gz
rails-83f24afd44ecd6fb6e38d5e8a6830dfca4bf5ffe.tar.bz2
rails-83f24afd44ecd6fb6e38d5e8a6830dfca4bf5ffe.zip
Add new finder methods to association collection.
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 25e329c0c1..b85d76e8d3 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -20,7 +20,22 @@ module ActiveRecord
super
construct_sql
end
-
+
+ delegate :group, :order, :limit, :joins, :where, :preload, :eager_load, :to => :scoped
+
+ def select(select = nil, &block)
+ if block_given?
+ load_target
+ @target.select(&block)
+ else
+ scoped.select(select)
+ end
+ end
+
+ def scoped
+ with_scope(construct_scope) { @reflection.klass.scoped }
+ end
+
def find(*args)
options = args.extract_options!
@@ -383,7 +398,7 @@ module ActiveRecord
loaded if target
target
end
-
+
def method_missing(method, *args)
if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method))
if block_given?