What is the equivalent of the has_many 'conditions' option in Rails 4?

后端 未结 5 1238
渐次进展
渐次进展 2020-12-02 12:11

Can someone tell me what is the equivalent way to do the following line in Rails 4?

has_many :friends, :through => :friendships, :conditions => \"statu         


        
5条回答
  •  青春惊慌失措
    2020-12-02 12:27

    has_many :friends, -> { where(status: 'accepted').order('first_name')}, through: :friendships
    

    or

    has_many :friends, -> { where(status: 'accepted').order(:first_name)}, through: :friendships
    

提交回复
热议问题