Hello all
I am working through an old (2010)
tutorial http://teachmetocode.com/screencasts/introduction-to-mongodb-part-iii-mongomapper-rails/ which uses an older version of mongodb. I need help with the syntax to open and read the yaml file mongdb.yml. I have attached the details and listed below is the original code and what I think it should be along with the errors I am getting.
Original snippet
configfile = "#{
RAILS_ROOT}/config/mongodb.yml"
if File.exist? configfile
config = YAML.load(File.read(configfile))[
RAILS_ENV]
Revised snippet (not working)
configfile = "#{
::Rails.root}/config/mongodb.yml"
if File.exist? configfile
config = YAML.load(File.read(configfile))[
Rails.env]
Snippet of error message
$
script/rails generate controller yasis/usr/local/rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/psych.rb:154:in `parse': (<unknown>): couldn't parse YAML at line 1 column 8 (Psych::SyntaxError)
from /usr/local/rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/psych.rb:154:in `parse_stream'
from /usr/local/rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/psych.rb:125:in `parse'
from /usr/local/rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/psych.rb:112:in `load'
from /var/www/html/mongo/mongodemo/config/initializers/mongodb.rb:5:in `<top (required)>'