Yowza. Due to some devine intervention I am now responsible to upgrade three rails sites. I started developing them in 2009, but haven't touched then since mid 2010. The persons who took over have not kept it up to date, nor (from their code) were they really good ruby programmers :)
So I have the daunting task to bring those projects into the present :)
Remember, 2010, rails 2.3.5? That seems like ages ago :) There was
vendor/plugins
instead of gemsAt first I couldn't even get the correct set of gems together to get the rails site running correctly.
So the steps I took to get it running (on my mac first) :
gem install rails
(which apparently installs the correct 2.3.5 version by itself --impressed :)rails_update
plugin (script/plugin)rake _0.8.7_
instead of the normal rake
it will work. Hehe.rails_upgrade
you have to have a working rails site, so I had to collect all gems in the correct versionsrails_upgrade
plugin to check/and upgrade routes/gems/...
environment.rb
using config.gem
)application.rb
needed to be edited (we added a lot of initializer code there --> should move to an initializer!)Then I switched (with rvm) to ruby 1.9.3 and ran bundle install
. Then I created a fresh 3.2.13 project and copied:
scripts
folder verbatimconfig/boot.rb
, config/environment.rb
and config/environments/*.rb
(make sure to check and keep any changes you made)Rakefile
(idem)Then I was good to go!! We still have a lot of vendor/plugins
I need to convert, one in particular I need to convert to an engine (gem).
Things I still need to do:
vendor/plugins
:
lib/plugins
And then I should have a running webapplication again. Wow.
Of course: the sites have no tests at all (my bad as well: when I started rails I did not know about testing), so will have to still add those. Starting with cucumber first, and add rspec later, when I touch the code (working from the outside in).
Comments
Bundler supports Rails 2, in my opinion adding bundler to a Rails 2 app _before_ any other changes would give more control and visibility for further actions. I've done it tis way for small sites. I also support a few huge rails 2 apps, and I don't plan the migration, the amount of work is too big for the customer to finance (or understand what this work at all) By the way, github is still Rails 2 :)
s/ what this work/ what this work is/
Yes, agreed it is a lot more work that I initially foresaw. Moving all js from rjs/prototype to jquery was a pain. A lot of `find_by_sql` which no longer worked. But it feels better being in unobtrusive js land and being able to use arels, gems, ... And maybe a lot of this work could be prepared in rails2. Now it was a lot to do in one big chunk. My previous experience porting to rails 3 where indeed rails 2 which were a bit more "up to date" (using jquery and bundler already).
Add comment