Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用CouchRest的Couchdb查找器_Ruby On Rails_Couchdb_Couchrest_Findby - Fatal编程技术网

Ruby on rails 使用CouchRest的Couchdb查找器

Ruby on rails 使用CouchRest的Couchdb查找器,ruby-on-rails,couchdb,couchrest,findby,Ruby On Rails,Couchdb,Couchrest,Findby,我只是想知道在使用couchdb的同时如何在Rails中构建find_all_by_action_和author_id方法。我的模型如下所示: class Activity < CouchRest::Model::Base property :action, String property :author_id, String end 我不知道如何获得正确的结果,我尝试了以下方法: Activity.by_action_and_author_id(:keys => [

我只是想知道在使用couchdb的同时如何在Rails中构建find_all_by_action_和author_id方法。我的模型如下所示:

class Activity < CouchRest::Model::Base
  property :action,    String
  property :author_id, String
end
我不知道如何获得正确的结果,我尝试了以下方法:

Activity.by_action_and_author_id(:keys => [['action','foo'], ['author_id', '1']]).all
但结果总是一个空哈希。最好的方法是什么?有什么例子吗

使用PostgreSQL时,它看起来是这样的

Activity.where(action: 'foo', author_id: '1').all
不可能这么复杂


Thanx查看一下生成的couchdb视图!您可以看到发出了哪些关键点。这里没有映射,所以我认为
[[['action','foo'],['author\u id','1']]]
应该是
['foo','1']

我不确定couchrest模型如何处理视图,但您可以在此处找到更多信息:

请看一下标记示例

Activity.where(action: 'foo', author_id: '1').all