Class: ActiveRecord::Associations::CollectionProxy
- Inherits:
-
Object
- Object
- ActiveRecord::Associations::CollectionProxy
- Defined in:
- lib/activerecord_sortable/collection_proxy.rb
Instance Method Summary collapse
Instance Method Details
#load_target ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/activerecord_sortable/collection_proxy.rb', line 8 def load_target if proxy_association.reflection.sortable? and order_values.empty? sortable_table_name = (proxy_association.try(:through_reflection) || proxy_association.reflection).table_name order("#{sortable_table_name}.#{proxy_association.reflection.sortable_field} ASC").to_a else original_load_target end end |
#original_load_target ⇒ Object
6 |
# File 'lib/activerecord_sortable/collection_proxy.rb', line 6 alias_method :original_load_target, :load_target |