views:

81

answers:

1

Hello,

I'm building a rails app above couchdb and decided to try the couch_potato and simply_stored gems as they seem add a nice feature set above the rest api and put the couchdb development 'on the rails'.

From what I can see SimlyStored/Couch works above the couch_potato layer, so from my understanding, the basic couch_potato features should be accessible from within a class that includes SimplyStored:: Couch.

However I was unable to use the view keyword in order to create custom views in a model that includes SimplyStored.

For instance, the following code :

Class MyExample
  include SimplyStored::Couch
  property :name
end

Will generate a design doc named _design/myexample that will contain a view named all_documents be used for the find(..) methods. This is indeed very nice.

However Changing the code to

Class MyExample
  include SimplyStored::Couch
  property :name
  view :example, :map => "function(doc) { emit(doc.name, null)}", :include_docs => true, :type => :custom
end

Won't add a view named example as I would expect, however I'm surely missing a point somwhere.

So if anyone has some suggestions on how to define additional custom views using those frameworks, I'd really appreciate.

Thanks,

A: 

OK, I have indeed missed something as the view declaration is not sufficient to create the view. We have to explicitly trigger the view creation, for instance by updating the class code to :

Class MyExample
 include SimplyStored::Couch
 property :name
 view :example, :map=>"function(doc) { emit(doc.name, null)}",:type => :custom
 CouchPotato.database.view MyExample.example
end
devlearn