-
Notifications
You must be signed in to change notification settings - Fork 19
Configuring a Fact Model
Tony Drake edited this page Nov 29, 2016
·
2 revisions
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.
class OrderFactModel < ActiveReporting::FactModel
end
You can manually declare what model a fact model will link to via the ActiveReporting::FactModel.use_model
method.
class OrderFactModel < ActiveReporting::FactModel
use_model SomeOtherModel
# OR you may pass in a string or symbol
# use_model :some_other_model
# use_model 'some_other_model'
# use_model 'SomeOtherModel'
end
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.
class OrderFactModel < ActiveReporting::FactModel
measure = :total
end