【发布时间】:2011-11-20 11:14:12
【问题描述】:
这是我的关联和范围设置:
has_many :owned_products
has_many :owned_lessons, :through => :owned_products, :source => :lesson, :conditions => "owned_products.product_type = 'Lesson'"
scope :active_purchase_scope, lambda {
where('owned_products.created_at' => (Date.today - CONFIG['downloads']['time_window'].days)..(Date.today)).order('owned_products.created_at DESC')
}
def active_lessons
owned_lessons.active_purchase_scope
end
这是我得到的错误:
ruby-1.8.7-p334 :005 > User.find_by_username('joeblow').active_lessons
NoMethodError: undefined method `active_purchase_scope' for #<User:0x1051a26c8>
大
【问题讨论】:
标签: ruby-on-rails activerecord scope associations