Ruby on rails 3 是否向控制器查找条件添加多个字符串?

Ruby on rails 3 是否向控制器查找条件添加多个字符串?,ruby-on-rails-3,activerecord,controller,conditional-statements,Ruby On Rails 3,Activerecord,Controller,Conditional Statements,我的一个Rails(3.1)控制器中有以下代码: @count = Call.where(:destination => current_user.destination_id).count @count_day = Call.where('created_at > ?', 1.days.ago).count @count_month = Call.where('created_at > ?', 30.days.ago).count 它们都按预期工作,但我正试图以某种方式将

我的一个Rails(3.1)控制器中有以下代码:

@count = Call.where(:destination => current_user.destination_id).count

@count_day = Call.where('created_at > ?', 1.days.ago).count
@count_month = Call.where('created_at > ?', 30.days.ago).count
它们都按预期工作,但我正试图以某种方式将其中两个合并在一起,以便显示在过去1天内创建的呼叫数,但仅适用于目标与当前用户目标id值匹配的呼叫

我试图添加:条件,但没有乐趣:

@count_day = Call.where(:destination => current_user.destination_id, :condition ['created_at > ?', 1.days.ago]).count
是否可以以这种方式添加多个条件?如果是,怎么做?

试试这个:

@count_day = Call.where("destination = :destination AND created_at > :date", { :destination => current_user.destination_id, :date => 1.days.ago}).count

其中创建了一个作用域,并且可以链接作用域,所以您可以这样做

Call.where(:destination =>current_user.id).where("created_at > ?", 1.day.ago).count

如果我使用您的代码
@count\u day=Call.where(:conditions=>['destination=(?)并在>(?)创建,当前用户.destination\u id,1.days.ago]).count
那么我会得到以下错误
SQLite3::SQLException:没有这样的列:calls.conditions:从“calls”中的“calls”中选择count(*),'destination=(?)并在>(?)创建条件“,'01772232427','2012-01-13 12:57:40.453694')
出于某种原因,输出的是
,而不是呼叫计数。如果您想要计数,请在末尾粘贴
.count
——我刚才说明了
可以链接到哪里