Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ArgumentError: Unknown key: :order. Valid keys are: :class_name, :anonymous_class in Rails 4.2.6

I am getting the following error while running rake db:migrate:

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

This is the model where I am getting error:

class Report < ActiveRecord::Base

  belongs_to :user
  has_many :icons, :order => 'position_id ASC' #showing error here..
  has_many :photos, :dependent => :destroy

end

Please help.

like image 513
user3189916 Avatar asked Jun 30 '16 09:06

user3189916


2 Answers

has_many :icons, -> { order('position_id ASC') }
like image 161
Joel Blum Avatar answered Oct 26 '22 19:10

Joel Blum


Duplicate.

has_many :icons, -> { order('position_id ASC') } #showing error here..

like image 30
Arpit Vaishnav Avatar answered Oct 26 '22 17:10

Arpit Vaishnav