Jump To Content

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')
leethal
  • Authority 5
Post Body
leethal said:

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.

  • Quote
  • Posted 3 months ago.
wmoxam
  • Authority 411
Post Body
wmoxam said in response to:
leethal
leethal’s post:
Citation Body

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.

Thanks for the clarification. Also, I believe that the ‘old way’ works in Edge rails. I could be wrong though.

  • Quote
  • Posted 3 months ago.
sgudi
  • Authority 10
Post Body
sgudi said:

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?

  • Quote
  • Posted 3 months ago.
wmoxam
  • Authority 411
Post Body
wmoxam said in response to:
sgudi
sgudi’s post:
Citation Body

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?

Have you upgraded those plugins to their newest versions? I use the newest version of exception_notifier, and it works exactly the same as previous versions.

The new Rails 2.1 compatible version of flex_image has an entirely different API. You can read more about it here: http://github.com/Squeegy/fleximage/wikis/gettingstarted

  • Quote
  • Posted 3 months ago.
leethal
  • Authority 5
Post Body
leethal said in response to:
wmoxam
wmoxam’s post:
Citation Body

Thanks for the clarification. Also, I believe that the ‘old way’ works in Edge rails. I could be wrong though.

Yeah it’s quite simple really: [action name].[mime extension].[template type]. And the mime extension part is optional. index.erb, index.rjs, index.xml.erb and show.js.builder is all valid =)

  • Quote
  • Posted 3 months ago.
Andrew Brown
  • Authority 530
Post Body
Andrew Brown said:

I’m on 2.1 now, Hurray!

  • Quote
  • Posted 3 months ago.
tompata
  • Authority 5
Post Body
tompata said:

Can anybody fix the has_many_polymorph plugin to Rails 2.1?

  • Quote
  • Posted 2 months ago.
wmoxam
  • Authority 411
Post Body
wmoxam said in response to:
tompata
tompata’s post:
Citation Body

Can anybody fix the has_many_polymorph plugin to Rails 2.1?

I’m using it with Rails 2.1. Do you have the latest version?

Here’s the git repo

  • Quote
  • Posted 2 months ago.
  • Your comment will be modifiable for 10 minutes after posted.

Page Author

Avatar
wmoxam
Name
wmoxam

From Here You Can…

Information

  • 4242 Views
  • 8 Comments
  • Ratings Likes 3 Negative 0

Most Recent Related Content

Published In…