Is it even worth it?
I'm working on assessing a legacy code base for a client -- the source code has been largely untouched since 2007 and it's built with Rails 1.2.3.
My Rails experience began at version 2.1 -- the code is fairly stock/scaffold like and devoid of meaningful tests -- I was curious to even see if I could get it running locally -- but开发者_开发问答, I'm not even sure where to start. Right off it doesn't even know what 'rake db:create' means. Ha!
Is it going be a major pain to even getting it running in 2.3.5? Should I bother?
Would love to hear your thoughts.
Thanks
If you're going to be actively developing the site, then yes, it is worth sinking the time into the project to bring it up to date. A lot has happened since Rails 1.2 which will make development a much more pleasant experience. Life without named scopes or RESTful resources is really difficult. If you're just patching the odd thing here and there, it may be worth leaving it mostly as-is and just dealing with the eccentricities.
Since 1.2.3 is just prior to the releases building up to 2.0 where a lot of warnings and deprecation notices were introduced, you could have quite a chore.
Some things to keep an eye out for:
- Migrations are now date-tagged, not numbered, but are at least backwards compatible
- Many vendor/plugins may not work, have no 2.x compatible version, or need to be upgraded
- The routing engine has changed, and the name of many routes may have changed, so see what rake:routes says and get ready for a lot of search-and-replace
I did this for a client with a smallish site. First, version control is your friend. Make sure you have the entire codebase committed.
Next, the basic recipe is as follows
- Tag the current source
- Update to the next release of rails (you'll have to google for the release announcement). My app was frozen, so I just had to freeze to that version
- rake rails:update to update the config, scripts and js
- Diff your working copy against the version in your scm. Make any changes necessary for the app
- Update any gems/plugins if necessary
- Start the app, exercise and test. Look for deprecation notices
- When it all looks good, commit to scm and tag
- Lather, rinse, repeat
For my client's app, it was much easier than I thought.
精彩评论