11

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.

user3189916
  • 758
  • 1
  • 7
  • 26
  • 1
    [http://stackoverflow.com/questions/18284606/deprecated-warning-for-rails-4-has-many-with-order](http://stackoverflow.com/questions/18284606/deprecated-warning-for-rails-4-has-many-with-order) – hypern Jun 30 '16 at 10:00

2 Answers2

18
has_many :icons, -> { order('position_id ASC') }
Joel Blum
  • 7,750
  • 10
  • 41
  • 60
1

Duplicate.

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

Community
  • 1
  • 1
Arpit Vaishnav
  • 4,739
  • 6
  • 39
  • 57