Jump To Content

LearnHub




Upgrading non-trivial apps to Rails 2.1

For simple Ruby on Rails apps that use very few plugins, upgrading may be as simple as:

rake rails:update

For everyone else, there may be some work to do.

Step 1: Upgrade incompatible plugins and gems

Internally, Rails has undergone many changes which broken compatibility with a variety of gems and plugins. Luckily most of them have been updated to be compatible with Rails 2.1

I had to upgrade the following:

active_scaffold, flex_image, haml, has_many_polymorphs, will_paginate

If you suspect that one of the plugins you use is causing problems, check for a newer version. There's a good chance that it's been upgraded to be Rails 2.1 compatible.

Step 2: Remove unneeded plugins

has_finder's functionality has been included in Rails 2.1 as 'named_scope'. The plugin will interfere with this functionality and crash your app. Simply remove the plugin, and change your code from 'has_finder' to 'named_scope'

Step 3: Remove hacks

Remember the garbage collection hacks? Get rid of them! The internals have changed, and at the very least they'll break ActiveRecord.

Step 4: Fix all of the code that you broke by upgrading your plugins.

Some plugins such as FlexImage have totally changed their api to be more 'rails compatible'. In this case you'll have to make some changes to comply with the new API interface

Step 5: Be explicit when rendering partials in xhr responses

Often an xhr response will do something like:

page.update_html 'some_element', render(:partial => 'some_controller/some_thing')

This may break in Rails 2.1, with an error message:

Missing template some_controller/_some_thing.js.erb

If you want to render a partial html template in a rjs template, you must specify the file extension.

page.update_html 'some_element', render(:partial => 'some_controller/some_thing.html.erb')

  1. leethal saidThu, 26 Jun 2008 06:14:07 -0000 ( Link )

    You can also rename views to just some_thing.erb. The MIME identifier isn’t mandatory, and not specifying it means that Rails will use that template for all mimes.

    Actions
    Vote
    Current Rating
    0
    Rate Up
    Rate Down
    No Votes

    Post Comments

  2. sgudi saidThu, 03 Jul 2008 08:10:47 -0000 ( Link )

    Hey,

    I am trying to upgrade my rails app from rails1.2.3 to rails 2.1. I am issues with fleximage: Can you please help me out on how exactly you upgraded fleximage. I use to have this in views: for bigger size: <%= image_tag (url_for({:controller => ‘images’ , :action => ‘thumb’, :id => @profile.photo}) %> in my app.

    For smaller size: <%= image_tag (url_for({:controller => ‘images’ , :action => ‘feed’, :id => @profile.photo}) %>

    I had defined different actions for feed and thumb in controller and flexi defined too..

    Can you help me out in upgrading this?

    I also had issues with exception_notifier and acts_as_rateable. Did you use these plugins?

    Actions
    Vote
    Current Rating
    0
    Rate Up
    Rate Down
    No Votes

    Post Comments

  3. Andrew Brown saidSun, 13 Jul 2008 18:43:17 -0000 ( Link )

    I’m on 2.1 now, Hurray!

    Actions
    Vote
    Current Rating
    0
    Rate Up
    Rate Down
    No Votes

    Post Comments

  4. tompata saidThu, 31 Jul 2008 09:21:36 -0000 ( Link )

    Can anybody fix the has_many_polymorph plugin to Rails 2.1?

    Actions
    Vote
    Current Rating
    0
    Rate Up
    Rate Down
    No Votes

    Post Comments

  5. senthil_rec83 saidWed, 31 Dec 2008 10:07:21 -0000 ( Link )

    I am upgrading from rails 2.0.2 to rails 2.1. I am using render template which points the template file out side of the project like, render :template =>”../../../Sites/website1/views/home’

    With rails 2.0.2, it is woking, but after upgrading to 2.1 it is not working. Can any one help me to fix this ?

    Thanks, Senthil

    Actions
    Vote
    Current Rating
    0
    Rate Up
    Rate Down
    No Votes

    Post Comments

Your Comment
Textile is Enabled (View Reference)