diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-07-20 13:32:55 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-07-20 13:33:49 +0100 |
commit | 7a271a8e844a4a5c931652a4a33a0d27445137c0 (patch) | |
tree | abd2f49e4c75e10dfd58cf566db51159f03d59d4 /activerecord/lib/active_record | |
parent | 3a07fdcf85672ac9727d9abe2a296a3b7c13c1c1 (diff) | |
download | rails-7a271a8e844a4a5c931652a4a33a0d27445137c0.tar.gz rails-7a271a8e844a4a5c931652a4a33a0d27445137c0.tar.bz2 rails-7a271a8e844a4a5c931652a4a33a0d27445137c0.zip |
Avoid options ever being nil
This fixes active_record_deprecated_finders.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/builder/association.rb | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index a90c5a2a9a..e266cf3335 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1192,7 +1192,7 @@ module ActiveRecord # ORDER BY p.first_name # } # } - def has_many(name, scope = {}, options = nil, &extension) + def has_many(name, scope = nil, options = {}, &extension) Builder::HasMany.build(self, name, scope, options, &extension) end @@ -1308,7 +1308,7 @@ module ActiveRecord # has_one :boss, :readonly => :true # has_one :club, :through => :membership # has_one :primary_address, :through => :addressables, :conditions => ["addressable.primary = ?", true], :source => :addressable - def has_one(name, scope = {}, options = nil) + def has_one(name, scope = nil, options = {}) Builder::HasOne.build(self, name, scope, options) end @@ -1431,7 +1431,7 @@ module ActiveRecord # belongs_to :post, :counter_cache => true # belongs_to :company, :touch => true # belongs_to :company, :touch => :employees_last_updated_at - def belongs_to(name, scope = {}, options = nil) + def belongs_to(name, scope = nil, options = {}) Builder::BelongsTo.build(self, name, scope, options) end @@ -1605,7 +1605,7 @@ module ActiveRecord # has_and_belongs_to_many :categories, :readonly => true # has_and_belongs_to_many :active_projects, :join_table => 'developers_projects', :delete_sql => # proc { |record| "DELETE FROM developers_projects WHERE active=1 AND developer_id = #{id} AND project_id = #{record.id}" } - def has_and_belongs_to_many(name, scope = {}, options = nil, &extension) + def has_and_belongs_to_many(name, scope = nil, options = {}, &extension) Builder::HasAndBelongsToMany.build(self, name, scope, options, &extension) end end diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb index 4a78a9c076..f45ab1aff4 100644 --- a/activerecord/lib/active_record/associations/builder/association.rb +++ b/activerecord/lib/active_record/associations/builder/association.rb @@ -16,12 +16,12 @@ module ActiveRecord::Associations::Builder @model = model @name = name - if options - @scope = scope - @options = options - else + if scope.is_a?(Hash) @scope = nil @options = scope + else + @scope = scope + @options = options end if @scope && @scope.arity == 0 |