aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-07-11 06:09:08 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-07-11 06:09:08 +0000
commit5b9b904f149f8ae41255096ba7b210c912329103 (patch)
treeba7c8c0e9c97024503b962158499d78bcd688096 /activerecord/lib/active_record/base.rb
parent16669774903dd7bfaaf1bf8f0c72e49ebaeffeeb (diff)
downloadrails-5b9b904f149f8ae41255096ba7b210c912329103.tar.gz
rails-5b9b904f149f8ae41255096ba7b210c912329103.tar.bz2
rails-5b9b904f149f8ae41255096ba7b210c912329103.zip
Added support for limit and offset with eager loading of has_one and belongs_to associations. Using the options with has_many and has_and_belongs_to_many associations will now raise an ActiveRecord::ConfigurationError #1692 [Rick Olsen]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1811 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index b32843d069..be64c1bbd3 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -26,6 +26,8 @@ module ActiveRecord #:nodoc:
end
class StaleObjectError < ActiveRecordError #:nodoc:
end
+ class ConfigurationError < StandardError #:nodoc:
+ end
class AttributeAssignmentError < ActiveRecordError #:nodoc:
attr_reader :exception, :attribute
@@ -336,7 +338,7 @@ module ActiveRecord #:nodoc:
case args.first
when :first
- find(:all, options.merge({ :limit => 1 })).first
+ find(:all, options.merge(options[:include] ? { } : { :limit => 1 })).first
when :all
options[:include] ? find_with_associations(options) : find_by_sql(construct_finder_sql(options))
else