... mostly about Ruby and Rails...

Mittwoch, 24. Juni 2009

How do I tell Couch Potato to use http authentication?

During RailswayCon, I attended the session 'Ruby sittin on the Couch' by Alexander Lang in which he mentioned couch.io: Managed Hosting and Support for Apache CouchDB and also his GitHub project couch_potato. And last weekend I decided to try that all out.

After setting up the DB on couch.io, I managed to access it via CURL, but it took me a long time and a hint by Alexander Lang to figure out how to tell couch_potato to use BASIC AUTHENTICATION. Actually, you cannot use the default CouchPotato.database method. You have to create your own database instance with the underlying CouchRest:

# define the CouchDB server through CouchRest
CouchServer = CouchRest::Server.new "http://user:password@account.couch.io"

# create the CouchRest database
CouchRestDB = CouchRest::Database.new CouchServer, "database"

# use that with CouchPotato
CouchDB = CouchPotato::Database.new(CouchRestDB)


P.S. this also ended up on the GitHub wiki page of couch_potato.

Keine Kommentare: