Skip to content
Browse files

push option handling "chrome" outside `initialize`

  • Loading branch information...
1 parent f7f422f commit 5b527dc39d1e6dbfbe1515a88bf0ee77706f1ded @tenderlove tenderlove committed Aug 1, 2013
Showing with 7 additions and 8 deletions.
  1. +7 −8 activerecord/lib/active_record/associations/builder/association.rb
View
15 activerecord/lib/active_record/associations/builder/association.rb
@@ -24,6 +24,11 @@ class << self
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 @@ def self.build(model, name, scope, options, &block)
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

0 comments on commit 5b527dc

Please sign in to comment.
Something went wrong with that request. Please try again.