【发布时间】:2013-08-28 12:57:45
【问题描述】:
a = Session.where(:date_at => date_from..date_to).
order("date_at").
count("DISTINCT(user_id)",
:group => "date(convert_tz(date_at, 'UTC', 'Europe/Warsaw'))")
如何在 Rails 4 中编写这个?
这会产生错误:
DEPRECATION WARNING: Relation#calculate with finder options is deprecated. Please build a scope and then call calculate on it instead. (called from block (2 levels) in <top (required)> at /Users/xxx/Desktop/DEPLOY/d1_mysql/d1/app/admin/user.rb:11)
DEPRECATION WARNING: The :distinct option for `Relation#count` is deprecated. Please use `Relation#distinct` instead. (eg. `relation.distinct.count`). (called from block (2 levels) in <top (required)> at /Users/xxx/Desktop/DEPLOY/d1_mysql/d1/app/admin/user.rb:11)
【问题讨论】:
标签: sql ruby-on-rails