CouchRest Rails Setup - Blank username/password issues
Setting a blank username/password is not the same as not setting a username/password
If you are using CouchRest in your Rails project and locally you don’t want to set a username and password for your couchdb install then bare in mind that the following are not the same;
CouchRest::Model::Base.configure do |config|
config.connection = {
:protocol => 'http',
:host => '127.0.0.1',
:port => 5984,
:prefix => '',
:suffix => Rails.env,
:join => '_'
}
end
The code above has no username and password set, so it will not try and speak to CouchDB with any credentials.
The code below has a username and password set but they are both blank, so it will try and speak to CouchDB with the username and password both being set to an empty string, this will result in a 401 Not authorised error.
CouchRest::Model::Base.configure do |config|
config.connection = {
:protocol => 'http',
:host => '127.0.0.1',
:port => 5984,
:prefix => '',
:suffix => Rails.env,
:join => '_',
:username => '',
:password => ''
}
end
This isn’t particularly unique to CouchRest at all but it tripped me up earlier so I figured I would share :-)