Попытка вернуть различные модели с помощью Ruby Activescaffold find для моделей с наследованием

StackOverflow https://stackoverflow.com/questions/2306694

Вопрос

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

Возможно ли сделать вышеописанное?

Спасибо!

Это было полезно?

Решение

ответил в соответствии с приведенным выше комментарием.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top