couchrest/couchrest_model — Issue #133: How to Access CouchDB documents by documentType property
Author: shreekumar
Created: 2011-12-02 05:00:41+00:00
State: open

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
end

and 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: #{
"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