Flowdock
method

build_scope

Importance_0
Ruby on Rails latest stable (v4.2.7) - 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 131
        def build_scope
          scope = klass.unscoped

          values         = reflection_scope.values
          reflection_binds = reflection_scope.bind_values
          preload_values = preload_scope.values
          preload_binds  = preload_scope.bind_values

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

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

          if preload_values[:reordering] || values[:reordering]
            scope.reordering_value = true
          end

          if preload_values[:readonly] || values[:readonly]
            scope.readonly!
          end

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

          scope.unscope_values = Array(values[:unscope]) + Array(preload_values[:unscope])
          klass.default_scoped.merge(scope)
        end
Register or log in to add new notes.