Module: ActiveRecord::Associations::Preloader::ThroughAssociation

Defined in:
lib/store_base_sti_class_for_3_1.rb

Instance Method Summary collapse

Instance Method Details

#through_optionsObject



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/store_base_sti_class_for_3_1.rb', line 152

def through_options
  through_options = {}
  if options[:source_type]
    #START PATCH
    #original: through_options[:conditions] = { reflection.foreign_type => options[:source_type] }
    through_options[:conditions] = { reflection.foreign_type =>  ([options[:source_type].constantize] + options[:source_type].constantize.descendants).map(&:to_s)  }
    #END PATCH
  else
    if options[:conditions]
      through_options[:include]    = options[:include] || options[:source]
      through_options[:conditions] = options[:conditions]
    end

    through_options[:order] = options[:order]
  end
  through_options
end