尝试使用 Ruby Activescafold 返回各种模型,在具有继承的模型上查找
class Promotion
def self.get_todays_promotions
# Promotion is a parent model, having child models e.g.
# DiscountPromotion, VoucherPromotion, etc.
# they all use a single table called promotions
# (and having 'type' field explaining which model they belong to)
promotions = self.find(:all, :conditions => [Promotion.date_check_query], :order => "#{Promotion.table_name}.order_of_calculation")
# Normally promotions would contain a collection of Promotion models.
# I want to return a collection of various models here depending on
# each model's class name
end
end
是否可以做到以上几点?
谢谢你!
class Promotion
def self.get_todays_promotions
# Promotion is a parent model, having child models e.g.
# DiscountPromotion, VoucherPromotion, etc.
# they all use a single table called promotions
# (and having 'type' field explaining which model they belong to)
promotions = self.find(:all, :conditions => [Promotion.date_check_query], :order => "#{Promotion.table_name}.order_of_calculation")
# Normally promotions would contain a collection of Promotion models.
# I want to return a collection of various models here depending on
# each model's class name
end
end
Is it possible to do the above?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回答如上面的评论。
answered as the comment above.