So i’ve got three models
"Text" has_many :statistics, :as => :loggable
"Document" has_many :statistics, :as => :loggable
"Statistic" belongs_to :loggable, :polymorphic => true
"Company" has_many "Documents"/"Texts"
now i want to get different restults, f.e.
- get the total count of statistic objects of all text/document objects of a company
- get the total count of statistic objects of all text/document objects of a company
this month - get the first five Texts/Documents of a company with the most statistic
objects - get the first five Texts/Documents of a company with the most statistic
objects this month
this month is related to the creation date of the statistic object.
i really have no idea how to achieve this. i tried different things in the rails console but without luck.
company.texts
company.documents
any ideas how to do this?
thanks in advance. please leave a comment if something is unclear.
The first 2 are pretty simple.
get the total count of statistic objects of all text/document objects
get the total count of statistic objects of all text/document objects this month
get the first five Texts/Documents of a company with the most statistic objects
get the first five Texts/Documents of a company with the most statistic objects this month