method
build
v3.0.0 -
Show latest stable
- Class:
ActiveRecord::Associations::ClassMethods::JoinDependency
build(associations, parent = nil, join_class = Arel::InnerJoin)protected
No documentation available.
# File activerecord/lib/active_record/associations.rb, line 1927
def build(associations, parent = nil, join_class = Arel::InnerJoin)
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).with_join_class(join_class)
when Array
associations.each do |association|
build(association, parent, join_class)
end
when Hash
associations.keys.sort{|a,b|a.to_s<=>b.to_s}.each do |name|
build(name, parent, join_class)
build(associations[name], nil, join_class)
end
else
raise ConfigurationError, associations.inspect
end
end