I'm putting together a little MVC framework with Sinatra and am puzzling over where to put the database configuration for the models.
At the moment I have this line in
config.ruSomeController.configure :development do
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/development.db")
end
SomeController.configure :production do
DataMapper.setup(:default, ENV['DATABASE_URL'])
end
But I want to be able to use the model files independently in irb and this will require the database setup. So I moved the configuration above into the model file and it didn't work because you need to require sinatra to be able to use configure blocks. I didn't want to have to require sinatra as I wanted the model files to stand on their own as just Ruby classes without any Sinatra.
So now I'm struggling as to where to actually put the database configuration.
Anybody got any good suggestions?
Cheers,
DAZ