Or, Rails without a database.
I found the first bug in the installation instructions for Beginning Rails. If you’re having trouble running the inaugural application (aptly named hello), it’s probably because we forgot to mention that Rails expects a database.
Without the hello_development database, browsing to http://localhost:3000/salutation/hello will result in something like this:
Mysql::Error (#42000Unknown database 'hello_development'): /usr/local/lib/ruby/gems/1.8/gems/activerecord/lib/active_record/vendor/mysql.rb:523:in `read'
In the interest of making apparent the irony, I draw your attention to the first paragraph of the chapter in question:
For various reasons, Rails has gained an undeserved reputation of being difficult to install. We want t dispel this myth.
Well, so much for dispelling the myth!
Remember how in the installation instructions we said that Rails was downright stubborn about working without a database? Well, we were right. Here Rails is obviously expecting a database called hello_development, but we didn’t create one!
There are two ways to fix this problem. You can either:
- make Rails happy by creating the required database, or
- edit Rails’ config file and tell it you’re not using a database for this application
Creating the database is perhaps the easiest way to go. You can flip ahead a few pages and read up on how it’s done, starting on page 47. But, if you’re impatient like I am, (and if you followed the installation instructions), you should be able to create the hello_development database thusly from the command line:
mysqladmin -uroot create hello_development
Stop the server using CTRL-C, and restart it using ruby script/server. Reload http://localhost:3000/salutation/hello and see if it works. If it does, great. Let’s just pretend this little mishap never happened. If it doesn’t, we’ll have to edit the config file.
Rails’ main config file is located in config/environment.rb. To configure Rails not to bother with a database, open it up in your text editor of choice and find the (commented out) line that reads:
# config.frameworks -= [ :active_resource, :action_mailer ]
Remove the comment and modify the line so that it excludes only ActiveRecord.
config.frameworks -= [ :active_record ]
Again, stop the server using CTRL-C, and restart it using ruby script/server. Reload http://localhost:3000/salutation/hello and all should be well.
Apologies for this ironically placed blunder!

