Search code examples
ruby-on-railstyphoeus

Getting a " undefined local variable or method " error


I run a command:

rake db:migrate RAILS_ENV=test    
ruby service.rb -p 3000 -e test

And I get this error:

, [2013-01-31T10:25:22.197106 #999] DEBUG -- : env: test
service.rb:16:in `<main>': undefined local variable or method `databases' for main:Object (NameError)

I am very new to Rails, can someone brainstorm on what are the things I should be looking at to find the issue? This is from a Tutorial on creating a client app for a Sinatra Rail service with Typheous

EDIT: Here is the link to the service.rb sourcefile that is giving error https://github.com/babakinks/HisFirstService/blob/master/service.rb


Solution

  • like Javid mentioned in the comment I was missing the line to define what is the variable "databases"

    Added this:

    databases = YAML.load_file("config/database.yml")
    

    Still have some more errors now but as far as this question, that's what was missing.