method

build

Importance_0
Ruby on Rails latest stable (v7.1.3.2) - 0 notes - Class: ActiveRecord::Associations::ClassMethods::JoinDependency

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v3.0.9) is shown here.

These similar methods exist in v7.1.3.2:

build(associations, parent = nil, join_type = Arel::InnerJoin) protected

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/associations.rb, line 1939
            def build(associations, parent = nil, join_type = 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?"
                  unless join_association = find_join_association(reflection, parent)
                    @reflections << reflection
                    join_association = build_join_association(reflection, parent)
                    join_association.join_type = join_type
                    @joins << join_association
                    cache_joined_association(join_association)
                  end
                  join_association
                when Array
                  associations.each do |association|
                    build(association, parent, join_type)
                  end
                when Hash
                  associations.keys.sort{|a,b|a.to_s<=>b.to_s}.each do |name|
                    join_association = build(name, parent, join_type)
                    build(associations[name], join_association, join_type)
                  end
                else
                  raise ConfigurationError, associations.inspect
              end
            end
Register or log in to add new notes.