Flowdock
method

build_scope

Importance_0
Ruby on Rails latest stable (v4.1.8) - 0 notes - Class: Association
build_scope() private

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/preloader/association.rb, line 133
        def build_scope
          scope = klass.unscoped

          values         = reflection_scope.values
          preload_values = preload_scope.values

          scope.where_values      = Array(values[:where])      + Array(preload_values[:where])
          scope.references_values = Array(values[:references]) + Array(preload_values[:references])

          scope._select!   preload_values[:select] || values[:select] || table[Arel.star]
          scope.includes! preload_values[:includes] || values[:includes]

          if preload_values.key? :order
            scope.order! preload_values[:order]
          else
            if values.key? :order
              scope.order! values[:order]
            end
          end

          if options[:as]
            scope.where!(klass.table_name => { reflection.type => model.base_class.sti_name })
          end

          klass.default_scoped.merge(scope)
        end
Register or log in to add new notes.