ActiveRecord関連で
Rails4で3系の書き方をしていたら、以下のようなwarningが発生した。
DEPRECATION WARNING: Relation#calculate with finder options is deprecated. Please build a scope and then call calculate on it instead. (called from hoge_check at /work/Fuga/app/models/tag.rb:103)
DEPRECATION WARNING: The :distinct option for `Relation#count` is deprecated. Please use `Relation#distinct` instead. (eg. `relation.distinct.count`). (called from hoge_check at /work/Fuga/app/models/tag.rb:103)
対処
countの中に条件(condition)を書くのではなく、
条件はwhere、カウントはcount、と分離して書けばok。
改善前
TagHistory.count(:conditions => {:action_id => @params.aid})
改善後
TagHistory.where(action_id: @params.aid).count()
改善前
TagHistory.count(:conditions => {:tag_id => self.id, :user_id => @user.id})
改善後
TagHistory.where(tag_id: self.id, user_id: @user.id).count()
解決。