This post is for beginners for Ruby on Rails who is learning from the Depot tutorial from the book: Agile Web Development with Rails 2nd Edition. The release of Rails 2.0.2 had deprecated some functions, and changed some defaults. I’m only started with Ruby on Rails for less than a week and still in the process of clearing a lot of doubts out.

This entry will mainly focus on getting you up and ready for Chapter 6 >> Iteration A1: Get Something Running. Specifically the parts I’ve identified so far that will cause problem is the switch in default database to sqlite3 (There should not be any problem if you have used sqlite3 for your database, but the ebook uses mysql for the walk-through)

This should cause the following error message in your command when you try to run rake:migrate

"require 'sqlite3'" gives "no such file to load -- sqlite3 (LoadError)"

To solve this problem, instead of running the following command in Chapter 6.1 (Pg 68)

rails depot

Run the following command to use mySQL as the default database.

rails -d mysql depot

There’s also a shortcut you can use. You can skip the following code to create a development database in mySQL manual on Page 69.

mysqladmin -u root create depot_development

Instead, you can go ahead to test your configuration as indicated on Page 71 through the following code

depot> rake db:migrate

If you don’t experience any error with the above command, it means that Rails is able to connect to your mySQL database server.

You might ask, “But I have not created my depot_development database yet”! That is where the beauty of Rails actually lie. Instead of going into the command prompt to create the database, you can use the rake command below to create the database for you.

rake db:create:all

The command creates three mySQL database for you, namely depot_development, depot_production, and depot_test. For the purpose of the tutorial, we just need the depot_development database, so you can type the following command

rake db:create

This automatically creates the development database for your current application. :)

The second change you’ll probably come across is due to a change in how scaffolding is performed in Rails 2.0.2. You will probably encounter the following error message when you try to access the URL (http://localhost:3000/admin).

As of now, I still can’t figure out how to draw the link between the Product model and the admin controller in the tutorial to work together yet. However, instead of following the instructions from Page 74 – 76 by running ruby script/generate model product, you can run

ruby script/generate scaffold Product title:text description:text image_url:string

A file named 001_create_products.rb will be created, with all the columns included, plus a default t.timestamp value. The t.timestamp automatically adds 2 columns of type datetime to your database (created_at, and updated_at).

You can access the same page in Pg 77 of the book, by going to http://localhost:3000/products. The new Rails scaffold automatically creates a controller named

if you did not specify the controller name. There you can start playing around with the adding, editing and deleting of records from the database.I know. It’s disconerting that the controller names are different. Having a products controller and an admin controller is not too different, but they still get on the nerves when you are going through the tutorials. Technically, the usage of scaffold in Rails is supposed to be script/generate scaffold ModelName [ControllerName] [action, ...]

I’m still trying to figure out why my the scaffold does not recognize my command

ruby script/generate scaffold Product Admin title:text description:text image_url:string

I get the following command line error

wrong number of arguments (1 for 2)

I update this post once I find the answer. Or if you happen to have solved that problem, let me know! :)