我最近将我的项目从rails3升级到rails4。我的模型中有以下代码,它在rails 4中失败
test_count = count(:all, :joins => joins, :conditions => conditions, :distinct => true)
上面的代码行给出了以下错误。
ArgumentError: Relation#count does not support finder options anymore. Please build a scope and then call count on it or use the activerecord-deprecated_finders gem to enable this functionality.
有关如何在rails 4中解决此错误的任何建议?
谢谢
答案 0 :(得分:0)
IMO您的查询转换为以下内容:
joins(joins).where(conditions).distinct.count
的Rails指南