How do you set the default order of resources coming out of the db. Something like:
has_many :trips, :order => 'departure_date DESC'
There is some business logic that needs the most recent date being checked first.
Current code results in this error.
ArgumentError (Unknown key: :order. Valid keys are: :class_name, :anonymous_class, :foreign_key, :validate, :autosave, :table_name, :before_add, :after_add, :before_remove, :after_remove, :extend, :primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache, :join_table, :foreign_type):
Was trying this as it received good reviews (6yrs ago.) Am I missing something simple or has that be depricated in favor of a better way today?
has_many :trips, -> { order(departure_date: :desc) }
Scroll down to "scopes"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With