我有一个(我认为)相对简单的has_many :through关联关系,其中涉及一个连接表: class User < ActiveRecord::Base has_many :user_following_thing_relationships has_many :thing...
ActiveRecord 在每次调用 save 方法时都会调用 after_save 回调,即使模型没有更改并且没有生成任何插入/更新查询。 实际上,这是默认行为。在大多数情况下,这是可以接受的。 但是,某些 after_save 回调对于模型是否实际保存敏感。 有没有办法在 after...
所以,我在“review”模型上有一个“after_save”钩子,调用产品模型的“calculate_specific_rating”函数。该函数的代码如下: def calculate_specific_rating ratings = reviews.reload.all.pl...