diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-10-07 12:43:04 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-10-07 12:43:04 -0300 |
commit | 9a958a3d7dc1640c90abbe1164d7ccb7ea9ae685 (patch) | |
tree | e4506fe2ccdbe51894d2e4d0d47f37e79545d603 /activerecord/lib | |
parent | aadb09b13bf2ca2eab4569f187e1cc42b007ba33 (diff) | |
download | rails-9a958a3d7dc1640c90abbe1164d7ccb7ea9ae685.tar.gz rails-9a958a3d7dc1640c90abbe1164d7ccb7ea9ae685.tar.bz2 rails-9a958a3d7dc1640c90abbe1164d7ccb7ea9ae685.zip |
Relations: Added offset when finding with associations. Delegate array instance
methods to to_a.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index db1c9c24de..6bc56ecf15 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -1,6 +1,7 @@ module ActiveRecord class Relation delegate :to_sql, :to => :relation + delegate :length, :collect, :find, :map, :each, :to => :to_a attr_reader :relation, :klass def initialize(klass, relation) @@ -34,7 +35,8 @@ module ActiveRecord :group => @relation.send(:group_clauses).join(', '), :order => @relation.send(:order_clauses).join(', '), :conditions => @relation.send(:where_clauses).join("\n\tAND "), - :limit => @relation.taken + :limit => @relation.taken, + :offset => @relation.skipped }, ActiveRecord::Associations::ClassMethods::JoinDependency.new(@klass, @eager_load_associations, nil)) end @@ -49,10 +51,6 @@ module ActiveRecord records end - def each(&block) - to_a.each(&block) - end - def first @relation = @relation.take(1) to_a.first |