Saturday, August 02, 2008

Ruby! (sqlite3 and Ruby on Rails)

I have been programming in Python for a while - To say 'programming' is a bit staid - I love python and I keep writing scripts just for the heck of it.

Of late, thanks to popularity of Ruby on Rails, I thought I'd learn Ruby - I started Ruby a week ago, and thanks to my super work-schedule, I haven't been able to spend a lot of time. But, since I already know python, it might be easier to learn Ruby.

I'll write more on how I feel Ruby is, and how it compares with Python as time goes.

To warm up on Rails, I got the book "Ruby on Rails - Up and Running" - I installed RoR using gems
c:\Sriram:\>gem install rails

Then when I started the server, and created the first controller (Greeting in the book) mentioned in the first chapter, I got the following error:

"no such file to load -- sqlite3"

[This error message appears in the web-page when I tried to load "http://localhost:3000/greeting"]

It has been a while since I did some web-programming. I panicked for a moment, but reassured myself that this problem should be trivial, and it was :-) (Yad Bhavam, Tad Bhavati [As you think so will it become])

I realised that I need to install sqlite - The database that was default in RoR. So, I went to sqlite download page , and downloaded the command line and the dll. (make sure the versions of the dll and the command line match to avoid surprises later) - I downloaded and I unzipped the dll and copied it to c:\windows\system32

Then I also installed sqlite3-ruby
c:\Sriram\Rails:\>gems install -r sqlite3-ruby

I then restarted the WEBrick server and voila! I could see the rendering of the text in index function of the controller in the web-page.

FYI, I am running on a quad-core PC with Windows Vista. Ruby 1.86. RoR 2.1

Btw, I downloaded the 'Instant Rails Package' - I have been trying to unzip the package for the past few hours. Looks like it is easier to get going with the gems installation of RoR and manual install of sqlite3 (Instant Rails may be more useful for a bigger project, but to get your hands wet, the above steps should do...)

No comments: