Topic: How to Access CouchDB documents by property in RoR CouchRest Gem
I'm using CouchRest model, my CouchDB contains many documents and has documentType as Survey, Response, Questions, Demo
What i need is accessing all document which has documentType as Survey, how can i do this in Rails 3 using CouchRest model?
here is my model
class Android < CouchRest::Model::Base
property :description, String
property :_id, String
property :_rev, String
property :documentType, String
view_by :documentType
endand i tried executing as follows in rails IRB console
irb(main):006:0> me=Android.find_by_documentType("Survey")But It's not working for me as expected, it's showing error like this
OkJson::Error: cannot encode CouchRest::Design: #<CouchRest::Design _id:
"_design/Android", language: "javascript", views: {"all"=>{
"map"=>"function(doc) {\n if (doc['type'] == 'Android')
{\n emit(doc['_id'],1);\n}\n}"}, "by_documentType"=>{"map"=>"function(doc)
{\n if ((doc['type'] == 'Android') && (doc['documentType'] ...........What is the problem here? am i doing it in correct way? please help me