Updating Rails
Ok, so I just had two days of headache because of Ruby on Rails. First of all, I must say that I actually really like programming in RoR and I think it’s a wonderful development in web programming. I’m barely into my first book of RoR (Agile Web Development with Rails, 2nd Ed.) and I already have a mostly functional shopping cart application with AJAX even! The book is wonderful, probably the best one out there for learning RoR (although I did read several chapters in the Pickaxe book on Ruby syntax which was very helpful for learning Ruby on Rails).
So my first problem was that the syntax in the book wasn’t generating the view it was supposed to. After searching around Google for a long time I finally realized that it was because I had an old version of rails installed (1.1.6 instead of 1.2.2) and the syntax was different in the old version. So I changed the syntax to the old version to make sure it would work, then set out to update rails. This turned out to be easy once I found the right command “gem update rails –include-dependencies”. Ok great. I type “rails -v” in the console and it tells me I have 1.2.2 installed. Excellent. So I fire up my WEBrick server and look at my application with the newer version syntax and … nothing. WHAT!?!
So finally I find out that the application is still running on rails 1.1.6. I have no idea why this is or how to fix it at this point. So another frantic Google search ensues. Several hours pass and I have no idea what to do so I go to bed. This morning I finally came across a reference to updating rails and then updating the individual apps, as they run on the rails version they were first created with. So this evening after work I finally figured out what to do. I had to open up environment.rb (located in my app’s directory\config) and change the line that says RAILS_GEM_VERSION to reflect my new version. Save. Re-run WEBrick and presto! It works.
Wow. I’m writing this in part to express my frustration, but also in case someone else is having this problem. Maybe their Google search will lead them to this page and that will be of some help.