Sunday, December 16, 2007

Rails 2.0

On Dec. 7th Rails 2.0 was unleashed onto the world.
We all know that Rails is very Web 2.0, though this 2.0 is not really that kind of 2.0, it's just Rails ver. 2.0.

Anyway, there are some cool things about it and some annoying things about it.

Most of the basic tutorials and books that I used to start learning RoR are now somewhat incompatible with Rails 2.0. This is especially true for the very basic stuff when getting started.
On the other hand, Rails 2.0 makes some very basic things easier to do.

For example, before Rails 2.0, you had to write some simple but obscure MySQL commands to set up the DB, before you even got started with your app.

In Rails 2.0 you can now create the DBs directly with Rails using:

rake db:create
This is cool and consistent with the fact that the rest of the DB interaction is done with Rails (via migrations).

Upgrading to Rails 2.0 with InstantRails didn't go smoothly.
When I ran the recommended command:
gem install rails -y
The install failed with the following message:
ERROR:  While executing gem ... (Zlib::BufError)
A little Googling revealed the following suggestion:
Try this command:
gem update --system
It will update your RubyGems to 0.9.5, and you will be able to install
Rails 2.0 without problem.
and indeed this worked for me, and properly updated InstantRails to Rails 2.0.

Update: as I was writing this post (somewhat retrospectively), I noticed that Rails 2.0.2 is out.
Although it is recommended to upgrade, what worries me is that the default DB now is SQLite3 and not MySQL. This means that new projects in InstantRails will probably not run out of the box since InstantRails is shipped with MySQL and not SQLite3. Changing the DB for a new project is apparently simple, but I have not done it so I cannot vouch for that:
If you want to preconfigure your database for MySQL (or any of the other adapters), you simply do “rails -d mysql myapp” and everything is the same as before. But if you’re just playing with a new application or building a smallish internal tool, then I strongly recommend having a look at SQLite3. Thanks to the agnostic db/schema.rb, it’s as easy as changing your config/database.yml to switch from SQLite3 to MySQL (or another database) as soon as your load warrants it.
Note that to upgrade you run the same command:
gem install rails
The -y switch (which appeared before) is to "Unconditionally install the required dependent gems". For more help on gem type gem on the command line (Ruby Console Window in InstantRails). For more help on gem install type:
gem help install

If you found this post helpful, please leave a message in the comments.
If you want to hear more about a Rookie and Rails, you can subscribe to the blog feed never miss out.

1 comment:

Elliott Goodwin said...

I am a Rails Rookie, too. I was coming up with some errors (the MySQL to SQLite issue), searched a little bit and come across your blog. Thanks for the information!