undefined method `env' for Rails:Module
I want to test the waters of mongodb together with RoR for a bit. I am trying to create the project with the following command:
rails mono_test_app -m http://gist.github.com/raw/284753/b5584c78fb5d29ab39a8218090801ea89b95a541/Rails%20MongoMapper%20Template
开发者_C百科
Part of the output is
create log/test.log
applying template: http://gist.github.com/raw/284753/b5584c78fb5d29ab39a8218090801ea89b95a541/Rails%20MongoMapper%20Template
executing rm public/index.html from /Users/olle/Projects/mono_test_app
executing rm public/images/rails.png from /Users/olle/Projects/mono_test_app
executing rm public/javascripts/controls.js from /Users/olle/Projects/mono_test_app
executing rm public/javascripts/dragdrop.js from /Users/olle/Projects/mono_test_app
executing rm public/javascripts/effects.js from /Users/olle/Projects/mono_test_app
executing rm public/javascripts/prototype.js from /Users/olle/Projects/mono_test_app
file app/views/layouts/application.html.erb
What should I call the database?
experiment
undefined method `env' for Rails:Module
Projects olle$
The template I am specifying with the -m parameter contains
# MongoDB FTW!
db_name = ask('What should I call the database? ')
initializer 'database.rb', <<-CODE
MongoMapper.database = "#{db_name}-#{Rails.env}"
CODE
file 'config/database.yml', <<-CODE
# Using MongoDB
CODE
Allot of people on github seem to have forked or cloned the gist and appear to use it, why on my system does this error occur? Am I missing something?
I have tried on both OSX and Ubuntu with ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.7.0] Rails 2.3.3
Rails.env
is the rails 3.0 way of doing it. If you're not using this version, use RAILS_ENV
instead
I think the reason is that somewhere in the code Rails.env
is used. This is rather new, I doubt if in rails 2.3.3 you can do that. Search for that phrase and replace it with RAILS_ENV
to see if this helps.
精彩评论