Class: ActiveRecord::Reflection::PolymorphicReflection
- Inherits:
-
Object
- Object
- ActiveRecord::Reflection::PolymorphicReflection
- Defined in:
- lib/store_base_sti_class.rb
Instance Method Summary collapse
Instance Method Details
#source_type_scope ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/store_base_sti_class.rb', line 137 def source_type_scope type = @previous_reflection.foreign_type source_type = @previous_reflection.[:source_type] # START PATCH adjusted_source_type = if ActiveRecord::Base.store_base_sti_class source_type else ([source_type.constantize] + source_type.constantize.descendants).map(&:to_s) end # END PATCH lambda { |object| where(type => adjusted_source_type) } end |