diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-10-26 13:20:02 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-10-26 13:20:02 +0000 |
commit | 0b92d38c0083c2077d0533014678ed017026fac1 (patch) | |
tree | 5127ff1b6bf11f9954932dbcec3c2b3bba6835ca /activerecord/lib/active_record/base.rb | |
parent | 07c494ae24b897bfa1d46f741b9ac14d3b480bc2 (diff) | |
download | rails-0b92d38c0083c2077d0533014678ed017026fac1.tar.gz rails-0b92d38c0083c2077d0533014678ed017026fac1.tar.bz2 rails-0b92d38c0083c2077d0533014678ed017026fac1.zip |
Added :offset and :limit to the kinds of options that Base.constrain can use (closes #2466) [duane.johnson@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2748 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 3ded347178..febb35dd5b 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -809,7 +809,8 @@ module ActiveRecord #:nodoc: end # Add constraints to all queries to the same model in the given block. - # Currently supported constraints are <tt>:conditions</tt> and <tt>:joins</tt> + # Currently supported constraints are <tt>:conditions</tt>, <tt>:joins</tt>, + # <tt>:offset</tt>, and <tt>:limit</tt> # # Article.constrain(:conditions => "blog_id = 1") do # Article.find(1) # => SELECT * from articles WHERE blog_id = 1 AND id = 1 @@ -883,6 +884,8 @@ module ActiveRecord #:nodoc: end def add_limit!(sql, options) + options[:limit] ||= scope_constraints[:limit] if scope_constraints[:limit] + options[:offset] ||= scope_constraints[:offset] if scope_constraints[:offset] connection.add_limit_offset!(sql, options) end |