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 anythingPreviously 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 symbolsPreviously 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 actionsWe 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 setIf 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 viewsRails 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 buildBecause 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 thoughts on “Rails 2.1.0 breakage

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s