rails without a database?
technology January 2nd. 2008, 8:12amI found out this morning that Rails really likes databases. It might even have some co-dependency issues.
I was trying to test out a few of the new features of Rails 2.0.2 in isolation - i.e. nothing that required a database in order to function - and I found that Rails was spitting up on me every time because I hadn't configured a database. I tried commenting out all DB connections in the database.yml config file, but that just made it feel like I was making fun of it.
The problem, as it happens, is that Rails loads ActiveRecord by default, whether I've defined any subclasses or not, and part of the module initialization is the creation of a new shared database connection for the application, whether it needs it or not. The simplest way to solve this is to keep Rails from loading the ActiveRecord framework by slipping the following line into one of your environment configuration files - environment.rb or the appropriate initializer for the environment you're working in:
config.frameworks -= [ :active_record ]
Rails is really marvelous at this sort of thing. I guess you could call it opinionated software that's reasonable enough to listen to what you as a programmer have to say.