Sunday, April 01, 2007

Ruby on Rails

I first read it on Wired about Ruby-on-Rails being the next big thing in web development. So, when I went to Borders last week and the geek that I am went straight to the computer's section and checked out the RoR book and bought it.

Most books, actually all books, leave out the error messages that I get. It is never smooth going with me and learning new software or systems. I had great adventures with installing mod chips on my Xbox, installing Ubuntu, installing Beryl on Ubuntu.. the list is long. The interesting thing about stuffing up is the solution is simple and there are many people who face the same issue, but the manuals turn up with blanks for the error messages I get. May be it was because of me not following the instructions (yes, I am the typical male) or just because I say 'Let me try this' and then it goes all awry.

I had to download and install Ruby Interpreter, Rails (the framework), RadRails, MySQL and MySQL Administrator just to start off. The Ruby and Rails went smooth, but MySQL started giving problems.

Errors with MySQL service starting:
When trying to start the service I got this message: "Could not start the service MySQL Error: 0", I looked up and found that running the command, "sc delete mysql" at the command prompt in DOS stops the already running service if it has been installed previously on the PC. I built the PC myself and I am sure that I have not installed MySQL before.

But that did not fix the issue, the "MySQL Server Instance Configuration Wizard" has to be run again, and you will have to select "Reconfigure Instance" and run the wizard all over to start it. That should fix the issue.

Errors with RadRails:
The instructions in the RoR book asked not to use a password, which I did read but did not follow and put in a password anyway. I have to admit I picked up a book in the Dummies series and that meant no password and all the easy options. That threw up a few surprises. When I created the table in the database through RadRails and then run Rake, I got "Could not connect to the database 'root'@'localhost' (using password: NO)", error message, that was simple to fix, as I knew that I did put in a password, when the book asked me not to, I had to go in somewhere and change it. Smart person that I am, I figured it out that the password has to be put in the database.yml file. In RoR parlance it is the yaml file. I had a smug feeling all over after I did that.

But after that I got another error message not letting me go through Rake: "28000Access denied for user 'root'@'localhost' (using password: NO)". This was interesting, I checked the password and it was correct in the yaml file. It had to be put in three times and all times it was correct. The fix is to leave a space after "password:" and then put in the actual password.

After this, I thought it would be all downhill and then I created the scaffold for my first database and tried to run it in the browser. The browser threw up a nice big error about "Access denied" again. Where do I change the password again? What do I do? I had to uninstall MySQL and MySQL Administrator and then reinstalled them, but the browser still will not run.

The solution was the restart the server on RadRails, so that it gets the new password details in, that did the trick. Now, I have to start my real studying of RoR.

My girlfriend was complaining that I was spending too much time with Ruby, little did she know that I was having so much fun. ;-)