However, when I call the average method in the Letsrate module, it searches for RatingCaches of the parent class (Resource), not the child class (Tutorial). In other words, when I call self.send("#{dimension}_average"), I get this SQL:
RatingCache Load (0.2ms) SELECT "rating_caches".* FROM "rating_caches" WHERE "rating_caches"."cacheable_id" = $1 AND "rating_caches"."cacheable_type" = $2 AND "rating_caches"."dimension" = 'name' ORDER BY "rating_caches"."id" ASC LIMIT 1 [["cacheable_id", 9], ["cacheable_type", "Resource"]] => nil
What needs to be changed so when saving and retrieving RatingCaches, the cacheable_type matches (either Tutorial or Resource)?
I have two models:
When I rate a
Tutorial
,RatingCache
saves the correct type (Tutorial
):However, when I call the
average
method in theLetsrate
module, it searches forRatingCaches
of the parent class (Resource
), not the child class (Tutorial
). In other words, when I callself.send("#{dimension}_average")
, I get this SQL:What needs to be changed so when saving and retrieving
RatingCaches
, thecacheable_type
matches (eitherTutorial
orResource
)?