Permalink
Browse files

push some validation up to the factory method

  • Loading branch information...
1 parent a6f568a commit a9087ab25a2886e724cd58448315aad3fa8005ae @tenderlove tenderlove committed Aug 1, 2013
Showing with 5 additions and 4 deletions.
  1. +5 −4 activerecord/lib/active_record/associations/builder/association.rb
@@ -22,13 +22,14 @@ class << self
attr_reader :model, :name, :scope, :options
- def self.build(*args, &block)
- new(*args, &block).build
+ def self.build(model, name, scope, options, &block)
+ raise ArgumentError, "association names must be a Symbol" unless name.kind_of?(Symbol)
+
+ builder = new(model, name, scope, options, &block)
+ builder.build
end
def initialize(model, name, scope, options)
- raise ArgumentError, "association names must be a Symbol" unless name.kind_of?(Symbol)
-
@model = model
@name = name

0 comments on commit a9087ab

Please sign in to comment.