method
build
v2.1.0 -
Show latest stable
- Class:
ActiveRecord::Associations::ClassMethods::JoinDependency
build(associations, parent = nil)protected
No documentation available.
# File activerecord/lib/active_record/associations.rb, line 1659
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