Upgrading Rails Engines Project to Rails 2.3.2

My lifestyleapps project (still in very early beta) was running Rails 2.2.2 with the Rails Engines plugin ten minutes ago. Today, Rails 2.3.2 was released so I decided to try if I could easily upgrade it and avoid using the Rails Engines plugin anymore. It was beautiful simple and took me less than ten minutes.

First, I had to update our Apache Passenger module with a version supporting Rails 2.3 so I did a

$ gem update passenger

and then run the install to build our apache module

$ passenger-install-apache2-module

In my config/environment.rb I changed

RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

to

RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION

and asked Rails to update my various script files by issuing

$ rake rails:update

Finally I remembered the application.rb should be named application_controller.rb now so I issued an explicit task for this as well

$ rake rails:update:application_controller

In the Rails Engines plugin you need to have the “routes.rb” file in the root of your plugin but with Rails 2.3.2 you should have it in the ‘config’ folder under your plugin and its content should be wrapped in “ActionController::Routing::Routes.draw do |map|” as the root routes.rb. So I changed this from

/vendor/plugins/life_intake/routes.rb

to

/vendor/plugins/life_intake/config/routes.rb

The contents of this routes.rb was changed from

map.resources :foods

to

ActionController::Routing::Routes.draw do |map|
  map.resources :foods
end

Finally I had to update the root “routes.rb” to avoid using the “from_plugin” call e.g. I simply removed lines such as

map.from_plugin :life_intake

Now I don’t need the Rails Engines plugin anymore so I removed it with

$ ./script/plugin remove engines

That’s it .. I was now able to run my tests and start up my project and have it run on Rails 2.3.2.

Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.