How should I upgrade a Rails app to use the latest version of Rails

后端 未结 7 699
鱼传尺愫
鱼传尺愫 2021-02-02 04:35

I\'m working on a Rails app that currently uses Rails 1.2, so I\'m now quite a long way behind the latest stable release (Rails 2.3).

How should I go about the process o

7条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-02 05:00

    I've just started upgrading a Rails 1.2.3 application to a Rails 2.3.4 environment. The basic steps and caveats that I encountered are:

    • Create a skeleton application similar to your basic application
    • Check any environment.rb settings that you have in the old application to see whether these are required in the new version.
    • Migrate all the .rhtml files over to .html.erb; either using a script or manual. In my case there were 100+ files so automating it was way easier
    • Check any routes.rb changes that might need to be made given that RoR2.3.4 has simplified specifying the routes.
    • Make sure you have a good SCM system at hand; eg either Git, SVN or even CVS so that small incremental changes can be captured.
    • Check what plugins you need. In the beginning I simply removed all the plugins and in fact some were obsolete for the functionality that was to be implemented in the ported application.
    • Update any form_tag entries; for example <%= form_tag :action => 'search' %> becomes `<% form_tag :action => 'search' do %> otherwise you'll get some interesting error messages
    • Likewise change the <%= end_form_tag%> to closing the block as in `<% end %>
    • Check if you have any plugins in the 1.2.3 version which are now removed from the core and have to be installed as plugins and configured for dependencies. I had some issues with the in_place_edit and calls made to the calendar popup.

    As others have said it can take longer than expected. I've done about 30hrs work on the migration. I had estimated it to take a lot longer; so that was good; but still have some more work on getting PDF generation going.

    Just to make it more interesting the application was running on a MS-Windows environment; Ruby 1.8.7, Rails 1.2.3 and MS SQL Server. The aim was to migrate to a Linux environment; Ruby 1.9.x, Rails 2.3.4 and MySQL database so that involved the MySQl server database migration tools.

提交回复
热议问题