You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tony Drake edited this page Nov 29, 2016
·
2 revisions
Linking a fact model to an ActiveRecord model
By default, a class inheriting from ActiveReporting::FactModel will assume the class is named [ModelName]FactModel. This will cause the fact model to link to an ActiveRecord model with the same name minus "FactModel".
For example, defining your fact model like the example below will auto link to the Order model.
You can manually declare what model a fact model will link to via the ActiveReporting::FactModel.use_model method.
classOrderFactModel < ActiveReporting::FactModeluse_modelSomeOtherModel# OR you may pass in a string or symbol# use_model :some_other_model# use_model 'some_other_model'# use_model 'SomeOtherModel'end
Configuring a fact model's measure
ActiveReporting assumes the column of a fact model used for summing, averaging, etc. is called value. This may be changed on a fact model using ActiveReporting::FactModel.meature=. You may pass in a string or symbol of the column you wish to use for aggregations.