我有以下代码:
def analytics
@user_registrations = User.count(:conditions => ["created_at >= ?", 30.days.ago.to_date], group: "date(created_at)")
@daily_count = []
30.times do |day|
@daily_count << [Date.today - day, @user_registrations['#{Date.today - day}']]
end
end
当运行时:<%= simple_format @user_registrations.to_yaml %>
产生:
--- !omap
- '2012-08-23': 11
我想取出11
值并将其放入我的 daily_count 数组中。
我怎样才能做到这一点?
更新:
<%= simple_format @user_registrations.to_yaml %>
<%= simple_format @daily_count.to_yaml %>
结果图像: