Rails 2.1.0 breakage

Rails 2.1.0 has many nice new features, but also it broke our app in some places.  This is what I found:

1. setup_with_fixtures no longer does anything

Previously we would use setup_with_fixtures in our tests to do setup actions, but it’s not called any more.  Just using plain old setup works for all our cases.

2. render :locals=>{} – hash keys must be symbols

Previously this would have worked

render :partial=>"something", :locals=>{"foo"=>"bar", "hoo"=>"haa"}

Now make sure all the locals are denoted by symbols

render :partial=>"something", :locals=>{:foo=>"bar", :hoo=>"haa"}

3. Relative paths when rendering actions

We were using double dots in our template paths when rendering actions from another controller, like this:

render :action=>"../controller/template"

This no longer works: instead try this:

render :template=>"controller/template"

4. Non null text columns in mysql will not default to empty string automatically if default is not set

If you happen to have a column of type text in your mysql database that is set to be NOT NULL and does not have a default set, then previously you would have got away without having to set a value explicitly for the column before saving an AR object.

This is not the case any more, ActiveRecord will set the value to nil/NULL and a database error will result when you try to save the object. So you need to set a value in your AR objects for these columns before saving. See here for details of the changes that cause this, and here for the associated bug report.

5. @action_name is no longer available in views

Rails is now careful not to export into the views some instance variables that were previously available. But just omit the @ – there is a new method action_name for this purpose. Or you could use @controller.action_name, or of course params[:action] to get the same information. See here for details of this issue.

6. Collection#size no longer works correctly on collections after they have been added to with build

Because of a bug in collection#size, it does not report the correct value after you have added additional items using collection#build. This bug has existed pre 2.1.0, but has only become an issue because this changeset causes build no longer automatically loading the collection. When size tries to calculate the size of the collection it correctly counts the collection members in the DB, but incorrectly counts the added-but-not-saved members as just 1, no matter how many more than one have been added.

I submitted a patch for this.

That’s all the issues we saw, it’s all working fine now. Go and upgrade now! (But don’t try to use Ruby 1.8.7, at least not until this is fixed)

2 comments for this post.

  1. Comment from Stephen Sykes | 4 June 2008 | 1:12 pm :

    The relative paths issue also broke the Exception Notification plugin.

    See here: http://blog.methodmissing.com/2008/2/4/exception-notification-and-edge

  2. Comment from Stephen Sykes | 3 July 2008 | 3:26 pm :

    Issue 6 (size of collections reported incorrectly) has now been patched in edge rails.

    http://github.com/rails/rails/commit/474d42538269a141687c7c66bef6575b4682b15d

Leave your comment...

Powered by WP Hashcash

Blog Archives

Navigation


About this blog

A blog about Ruby, Rails and other tech. Mostly.


Find Something?