has_many line_items has_many products, :through => :line_items
因为我在中间表添加了一个属性,想搜索出当这个属性为 null 的 product! 可以在
has_many products, :through => :line_items
添加条件?
rails 4
class Customer < ActiveRecord::Base has_many :confirmed_orders, -> { where "confirmed = 1" }, end
rails 3
class Customer < ActiveRecord::Base has_many :confirmed_orders, :conditions => "confirmed = 1" end