method
build
v2.2.1 -
Show latest stable
-
0 notes -
Class: ActiveRecord::Associations::ClassMethods::JoinDependency
build(associations, parent = nil)
protected
Hide source
# File activerecord/lib/active_record/associations.rb, line 1893 def build(associations, parent = nil) parent ||= @joins.last case associations when Symbol, String reflection = parent.reflections[associations.to_s.intern] or raise ConfigurationError, "Association named '#{ associations }' was not found; perhaps you misspelled it?" @reflections << reflection @joins << build_join_association(reflection, parent) when Array associations.each do |association| build(association, parent) end when Hash associations.keys.sort{|a,b|a.to_s<=>b.to_s}.each do |name| build(name, parent) build(associations[name]) end else raise ConfigurationError, associations.inspect end end