Deprecated warning for Rails 4 has_many with order

前端 未结 5 1846
情话喂你
情话喂你 2020-11-27 14:08
class RelatedList < ActiveRecord::Base
  extend Enumerize

  enumerize :list_type, in: %w(groups projects)

  belongs_to :content
  has_many :contents, :order =&g         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 14:26

    Alternatively, you can put the order clause on the model, for instance:

    has_many :options, order: 'name' # In class Answer
    

    Becomes

    has_many :options # In class Answer
    
    default_scope { order 'name' } # In class Option
    

    PS: I got ArgumentError: wrong number of arguments (1 for 0) when doing has_many :things, -> {}.

提交回复
热议问题