i'm in the middle of my upgrade and am running into some problems.
Here is my error:
/Users/jay/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/core_ext/hash/keys.rb:71:in `block in assert_valid_keys': Unknown key: :order. Valid keys are: :class_name, :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 (ArgumentError)
Does it have something to do with my scopes? For example:
scope :total_views, order('total_views DESC')
or
default_scope { order: :sort_order }
or
scope :recent, order: 'created_at desc'
I have bunch of scopes that use order, what is going on?
Named scopes in Rails 4 take lambdas now instead of hashes. Within a lambda use the new query syntax and not the old hash syntax:
default_scope { order(:sort_order) }
scope :total_views, -> { order('total_views DESC') }
scope :recent, -> { order('created_at DESC') }
Read more about ActiveRecord querying: http://edgeguides.rubyonrails.org/active_record_querying.html#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