我正在使用名为acts_as_paranoid
的gem,它可以删除逻辑。
1. <% @codes_confirmed_count = Code.where(:deleted_at => nil, :created_at => check_date.beginning_of_day..check_date.end_of_day).count %>
2. <% @codes_all_count = Code.where(:created_at => check_date.beginning_of_day..check_date.end_of_day).count %>
这些代码返回相同的值。
第二个应该返回大于第一个的值,因为没有:deleted_at => nil
但确实有一些记录被删除(这意味着日期时间值为deleted_at
列)
我如何在这里忽略acts_as_paranoid?
答案 0 :(得分:2)
我认为您可以通过
获取所有代码(已删除+未删除)的计数<% @codes_all_count = Code.with_deleted.where(:created_at => check_date.beginning_of_day..check_date.end_of_day).count %>
您可以参考他们的github page寻找更多方法。