upgrading rails 2.3.5 to rails 3.2.13

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

  • no bundler
  • no rvm (actually, still isn't since they deploy on windows --aaaaarggh since then I develop on ubuntu and mac)
  • vendor/plugins instead of gems
  • no asset pipeline
  • old routes

At 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) :

  • create a new branch
  • use rvm to switch to start using 1.8.7 and a new empty gemset
  • gem install rails (which apparently installs the correct 2.3.5 version by itself --impressed :)
  • install rails_update plugin (script/plugin)
  • my current rake version is not compatible, luckily if you type rake _0.8.7_ instead of the normal rake it will work. Hehe.
  • to get to use rails_upgrade you have to have a working rails site, so I had to collect all gems in the correct versions
  • using rails_upgrade plugin to check/and upgrade routes/gems/...
    • the routes generated where correct
    • the gemfile I had to edit manually (the used gems were not specified in the environment.rb using config.gem)
    • also the generated 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:

  • the scripts folder verbatim
  • the config/boot.rb, config/environment.rb and config/environments/*.rb (make sure to check and keep any changes you made)
  • the 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:

  • convert vendor/plugins:
    • convert engine to gem
    • convert others to lib/plugins
  • move assets to asset pipeline

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
Yuri Leikind 2013-06-05 10:55:50 UTC

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 :)

Yuri Leikind 2013-06-05 10:56:33 UTC

s/ what this work/ what this work is/

nathanvda 2013-06-17 08:36:07 UTC

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

Recent comments

Tags

ruby on rails 34 ruby 26 rails3 17 rails 15 oracle 11 rspec 9 rspec2 7 jquery 7 ubuntu 5 javascript 5 windows 5 activerecord 3 refactoring 3 geoserver 3 gis 3 arrrrcamp 3 actionmailer 2 oracle spatial 2 tdd 2 postgis 2 routing 2 rvm 2 mongoid 2 csharp 2 thin 2 win32 2 gem 2 rails4 2 git 2 service 2 haml 2 cucumber 2 view testing 2 i18n 1 displaysleep 1 spatial 1 gemsets 1 wubi 1 oracle_enhanced_adapter 1 migrations 1 watchr 1 ci 1 plugins 1 coderetreat 1 ie8 1 ssl 1 oci 1 nested model form 1 wcf 1 11.04 1 jsonp 1 ruby-oci8 1 teamcity 1 engines 1 pgadmin 1 soap 1 content_for 1 word automation 1 plugin 1 capybara 1 xml 1 bootstrap 1 migrate to rails3 1 mvc 1 unity 1 rendering 1 word2007 1 x64 1 limited stock 1 fast tests 1 pl/sql 1 delayed_job 1 pdf 1 test coverage 1 optimization 1 processing 1 borland 1 method_missing 1 cross-browser 1 devise 1 schema_plus 1 mongo 1 mongrel 1 dual boot 1 usability 1 mongrel_service 1 dba 1 mission statement 1 model 1 metadata 1 rcov 1 exceptions 1 image_tag 1 attachments 1 bde 1 css 1 yield 1 ajax 1 generative art 1 rails-assets 1 coordinate systems 1 submodules 1 netzke 1 ora-01031 1 authlogic 1 postgresql 1 shopping cart 1 agile 1 fast_tagger 1 subjective 1 wice_grid 1 generators 1 nvidia 1 mongodb 1 etsyhacks 1 staleobjecterror 1 session 1 jeweler 1 wordpress hacked 1 jasmine 1 heroku 1 rjs 1 life 1 unobtrusive-javascript 1 render_anywhere 1 html5 1 rails31 1 json 1 cocoon 1 mingw32 1 observe_field 1 osx 1 actionwebservice 1 testing 1 debugging 1 strings 1