English 中文(简体)
如何与活跃的Record或Mongoid撰写这一询问?
原标题:How to write this query with ActiveRecord or Mongoid?

邦戈德和“积极记录”这两个接口都相当相似,因此,我认为它们或将会发挥作用。 我需要询问是否符合以下标准。

我需要知道过去10天中某类谷物吃的天数。 谷物每天可以吃10次,但我只需要知道,该日至少吃了1次谷物。 因此,如果今天是第11位,用户在第5次、第7次10次、第8次、第3次、第5次、第5次、第5次、第5次、第5次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次、第3次。

如何做类似于“积极观察”或“刚果”的询问? 基础等级为Cereal,有点名。

问题回答

我不知道。 Cereal. where (:last_eaten.gt => Annual.today - 10.day) or some such as that in mongoid ? 我在座谈一下,也许不能完全正确。

如果没有适当的模式样本,很难回答。

如果你的模式符合我所铭记的内容(类似于卡坦的答复):

Cereal.where("date > ?", Date.today - 10.days).select("distinct(date)").count

你可能不得不把它 t为bit,但这基本上需要你做些什么。





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签