Setting passwords on Buckets for Ruby SDK


#1

Hi,
I am a newbie working on Couchbase and faced the following problem. I tried google for answers and looked through the forum as well. My configuration is as per detailed and it will be great to receive any advices or hints to do this.
Taking the example of “testbucket” with password “password” and the following configuration.

  1. hostname: localhost
  2. port: 8091/ 11211
  3. username: testbucket
  4. password: password
  5. bucket: testbucket

#2

post your config/couchbase.yml please


#3

Sorry I forgot to add the error message. When trying to run rails console --sandbox I get the error below that does not occur when I remove the password from the bucket.

darren@darren-VirtualBox:~/Development/Playground/learnrailscouchbase$ rails console --sandbox
/home/darren/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown>): could not find expected ':' while scanning a simple key at line 4 column 3 (Psych::SyntaxError)
	from /home/darren/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
	from /home/darren/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/psych.rb:153:in `parse'
	from /home/darren/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/psych.rb:129:in `load'
	from /home/darren/.rvm/gems/ruby-2.0.0-p195@learnrailscouchbase/gems/couchbase-model-0.5.2/lib/couchbase/railtie.rb:91:in `block in <class:Railtie>'
	from /home/darren/.rvm/gems/ruby-2.0.0-p195@learnrailscouchbase/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
	from /home/darren/.rvm/gems/ruby-2.0.0-p195@learnrailscouchbase/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
	from /home/darren/.rvm/gems/ruby-2.0.0-p195@learnrailscouchbase/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
	from /home/darren/.rvm/gems/ruby-2.0.0-p195@learnrailscouchbase/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
	from /home/darren/.rvm/gems/ruby-2.0.0-p195@learnrailscouchbase/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
	from /home/darren/.rvm/gems/ruby-2.0.0-p195@learnrailscouchbase/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
	from /home/darren/.rvm/gems/ruby-2.0.0-p195@learnrailscouchbase/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
	from /home/darren/Development/Playground/learnrailscouchbase/config/environment.rb:5:in `<top (required)>'
	from /home/darren/.rvm/gems/ruby-2.0.0-p195@learnrailscouchbase/gems/railties-3.2.13/lib/rails/application.rb:103:in `require'
	from /home/darren/.rvm/gems/ruby-2.0.0-p195@learnrailscouchbase/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
	from /home/darren/.rvm/gems/ruby-2.0.0-p195@learnrailscouchbase/gems/railties-3.2.13/lib/rails/commands.rb:40:in `<top (required)>'
	from script/rails:6:in `require'
	from script/rails:6:in `<main>'

#4

Hi,
This is the yml file. Thanks.

common: &common
  hostname: localhost
  port: 8091
  username:testbucket
  password:password
  pool: default
 
development:
  <<: *common
  bucket: testbucket
 
test:
  <<: *common
  bucket: testbucket
 
# set these environment variables on your production server
production:
  hostname: <%= ENV['COUCHBASE_HOST'] %>
  port: <%= ENV['COUCHBASE_PORT'] %>
  username: <%= ENV['COUCHBASE_USERNAME'] %>
  password: <%= ENV['COUCHBASE_PASSWORD'] %>
  pool: <%= ENV['COUCHBASE_POOL'] %>
  bucket: <%= ENV['COUCHBASE_BUCKET'] %>

#5

What kind of problem did you face?


#6

line 4:

username:testbucket

i think psych YAML parser expects

username: testbucket

Checkout this example IRB session:

irb> YAML.load("test:\n  foo: 1\n  bar: 2")
{"test"=>{"foo"=>1, "bar"=>2}}
irb> YAML.load("test:\n  foo:1\n  bar: 2")
Psych::SyntaxError: (<unknown>): mapping values are not allowed in this context at line 3 column 6
        from /home/avsej/.rbenv/versions/2.0.0-p0-dbg/lib/ruby/2.0.0/psych.rb:205:in `parse'
        from /home/avsej/.rbenv/versions/2.0.0-p0-dbg/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
        from /home/avsej/.rbenv/versions/2.0.0-p0-dbg/lib/ruby/2.0.0/psych.rb:153:in `parse'
        from /home/avsej/.rbenv/versions/2.0.0-p0-dbg/lib/ruby/2.0.0/psych.rb:129:in `load'
        from (irb):10
        from /home/avsej/.rbenv/versions/2.0.0-p0-dbg/bin/irb:12:in `<main>'