views:

61

answers:

1

Hi All

I'm just starting to learn my way around CouchDB and Sinatra, but am struggling to find some basic examples of integrating the two via CouchRest. The CouchRest docs assume a little too much to be useful to me yet.

Does anyone have links to useful examples/articles/docs?

A: 

Sinatra docs are pretty great and easy to work with.

The examples in the couchrest repo seem to show a lot of use cases. http://github.com/jchris/couchrest/blob/master/examples/model/example.rb

The best way to understand code (and especially bleeding edge ruby) is to just read the code.

Ben Hughes
I have looked at that example, but I was struggling to understand how it would fit into Sinatra. For example, the `SERVER` and `SERVER.default_database` properties... Could they live in a rackup file as they are?
safetycopy
don't put them in the rackup file. You should probably have a separate configuration file (analogous to config/environment.rb in rails). There is nothing special about couch rest or sinatra, it is just normal ruby.
Ben Hughes
OK, thanks for the tip, Ben :-) Also, after playing around a bit more I've realised that the code in that `example.rb` file is quite dated now. It may be useful for showing a general outline, but it seems the CouchRest API has changed since the example was written (for example, `save` does not work for me but `save_doc` does).
safetycopy
I wish I could say I was more surprised. Most of the time when I am working with all but the most commonly used libraries I find myself only reading source code and tests to find out how something works.
Ben Hughes