diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-08-01 11:55:09 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-08-01 11:55:09 -0700 |
commit | 5b527dc39d1e6dbfbe1515a88bf0ee77706f1ded (patch) | |
tree | bc978225f42a719bdd8a976386ae656bd7952707 /activerecord | |
parent | f7f422f1b3a5ee4eec90f71cb7ad3f5cdeb8957f (diff) | |
download | rails-5b527dc39d1e6dbfbe1515a88bf0ee77706f1ded.tar.gz rails-5b527dc39d1e6dbfbe1515a88bf0ee77706f1ded.tar.bz2 rails-5b527dc39d1e6dbfbe1515a88bf0ee77706f1ded.zip |
push option handling "chrome" outside `initialize`
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/association.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb index bdde25bd38..22bc005b05 100644 --- a/activerecord/lib/active_record/associations/builder/association.rb +++ b/activerecord/lib/active_record/associations/builder/association.rb @@ -24,6 +24,11 @@ module ActiveRecord::Associations::Builder def self.build(model, name, scope, options, &block) raise ArgumentError, "association names must be a Symbol" unless name.kind_of?(Symbol) + if scope.is_a?(Hash) + options = scope + scope = nil + end + builder = new(name, scope, options, &block) reflection = builder.build(model) builder.define_accessors model @@ -34,14 +39,8 @@ module ActiveRecord::Associations::Builder def initialize(name, scope, options) @name = name - - if scope.is_a?(Hash) - @scope = nil - @options = scope - else - @scope = scope - @options = options - end + @scope = scope + @options = options validate_options |