以前は、以下のコードを使用して、ネストされた割引リソースを含む顧客リソースを正常にレンダリングしていました。
class Discount < ActiveRecord::Base
belongs_to :customer
end
format.json { render json: Customer.find(params[:id]), :include => { :discounts =>
{:include => {...}
}}
}}
後で割引にスコープを追加しました。
class Discount < ActiveRecord::Base
belongs_to :customer
scope :current, where('(begin_on <= ? OR begin_on IS NULL) AND (? <= end_on OR end_on IS NULL)', Date.today, Date.today)
end
上記のjson呼び出しで、すべてのCustomer.discountsではなく、これらの現在の割引のみをレンダリングするにはどうすればよいですか?