I'm trying to write a config.ru file for Sinatra where I have one set of database credentials for each environment: development and production. I'm doing the following:
# ... the rest of the app
require './app.rb' # the app itself
configure :development do
set :db_name, 'thedatabase'
set :db_user, 'root'
set :db_password, ''
set :db_server, 'localhost'
Looks like it might be an ordering problem. If that
DataMapper.setup(...) line is really at the top level of
app.rb, it will be called as soon as you
require './app.rb', before
configure has run.
It's best not to do any work upon loading a file. Use some form of explicit or lazy initialization instead.