Module: ActiveRecord::QueryMethods

Defined in:
lib/monkey_patch_activerecord.rb

Overview

module Persistence

Instance Method Summary collapse

Instance Method Details

#build_select(arel) ⇒ Object

This method is patched to change the default behavior of select to use the Relation’s Arel::Table



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/monkey_patch_activerecord.rb', line 93

def build_select(arel)
  if !select_values.empty?
    expanded_select = select_values.map do |field|
      columns_hash.key?(field.to_s) ? arel_table[field] : field
    end
    arel.project(*expanded_select)
  else
    # ****** BEGIN PARTITIONED PATCH ******
    # Original line:
    # arel.project(@klass.arel_table[Arel.star])
    arel.project(table[Arel.star])
    # ****** END PARTITIONED PATCH ******
  end
end