Rails 2.3.3: Touching, faster JSON, bug fixes

Posted by David July 20, 2009 @ 05:28 PM

We’ve released Ruby on Rails version 2.3.3. This release fixes a lot of bugs and introduces a handful of new features.

Active Record

  • touch is a convenient method to update a record’s timestamp and nothing else. This is extracted from apps whose models “touch” others when they change, such as a comment updating the parent.replies_changed_at timestamp after save and destroy. Timestamping an entire has_many association makes it easy to build a key for fragment caching that covers changes to the parent object and any of its children. This pattern is wrapped up as belongs_to :parent, :touch => :replies_changed_at. When the child changes, parent.replies_changed_at is touched. :touch => true is defaults to :touch => :updated_at.
  • :primary_key option for belongs_to for broader support of legacy schemas and those using a separate UUID primary key: belongs_to :employee, :primary_key => 'SSN', :foreign_key => 'EMPID' changeset

JSON

  • decoding backends for the json and yajl libraries. Both are significantly faster than the default YAML backend. To get started, install the json gem and set ActiveSupport::JSON.backend = 'JSONGem'.
  • leaner user-facing encoding API. Since a JSON libraries implement to_json with varying compatibility, safely overriding it is difficult. Most custom to_json looks like
    
    def to_json(*encoder_specific_args)
      { :some => "json representation" }.to_json(*encoder_specific_args)
    end
    so we DRYed the user-facing API down to a more natural
    
    def as_json(options = {})
      { :some => "json representation" }
    end
    without the ugly internal state exposed by overloading to_json as both public-facing and internal builder API. Rails 3 splits the API explicitly, so prepare now by switching from to_json to as_json.

Other Features

  • Add :concat option to asset tag helpers to force concatenation. changeset
  • Restore backwards compatibility for AR::Base#to_xml. changeset
  • Move from BlueCloth to Markdown for the markdown helper. Users using BlueCloth to provide their markdown functionality should upgrade to version 1.0.1 or 2.0.5 in order to restore compatibility.

Notable Bug Fixes

  • Fix errors caused by class-reloading with streaming responses in development mode.
  • Several fixes to the gem bundling, unpacking and installing system.
  • Make text_area_tag escape contents by default.
  • Make filter_parameters work correctly with array parameters.
  • Thread-safety fixes for postgresql string quoting.
  • Performance fixes for large response bodies.

40 comments

Comments

  1. Jerod Santo on 20 Jul 17:40:

    Does this release include the publicized authentication bug fix? if so, seems like that would be notable enough to include here.

  2. Rizwan Reza on 20 Jul 17:41:

    Shouldn’t touch behavior be default for updated_at for all has_many associations?

  3. Michael Johann on 20 Jul 17:45:

    Thank you for the release. Any new estimations regarding Rails 3?

  4. Donnie on 20 Jul 17:55:

    Will this be the last release before 3.0?

  5. Erik on 20 Jul 18:07:

    Thanks (again) for all the hard work!

  6. Paul on 20 Jul 18:37:

    @Rizwan Reza

    Definitely not. Here is one example. class has_many students. Just because a class gets moved to a different room doesn’t mean that any of the students changed.

  7. Thiago Taranto on 20 Jul 18:39:

    Thanks a lot!

  8. Dejan Dimic on 20 Jul 19:06:

    Nice release to play with in this vacation weeks. Thank You all for it.

  9. mrkris on 20 Jul 19:21:

    Looks pretty neat, time to upgrade again.

  10. Peter Hellberg on 20 Jul 19:33:

    A :primary_key option for belongs_to was exactly what I needed today… and here it is!

    Thank you guys for all the hard work.

  11. Jared Dobson on 20 Jul 19:53:

    Nice work! Thanks David!

  12. Ben Johnson on 20 Jul 20:20:

    This is nice, but am I the only person all of a sudden getting?

    ArgumentError (A copy of XXX has been removed from the module tree but is still active!)

    I noticed changes were made with class reloading. I’m not doing anything tricky. I’m mainly getting this with helpers modules and what not. I know turning cache-classes on for development solves the problem, but this just seems odd as I was not getting this before.

  13. Yehuda Katz on 20 Jul 20:39:

    @donnie I doubt it. As we get closer to 3.0, there will probably be another release with some transitional help (deprecation warnings etc.)

  14. Rodrigo Alves Vieira - rav on 20 Jul 21:10:

    Thank you guys! David and all the Rails core team and Contributors. We were all waiting for Rails 2.3.3! :-)

  15. Khalid Shaikh on 20 Jul 21:25:

    Great work!! I already upgraded.

  16. eep on 20 Jul 21:36:

    hm, load order change borked my tests.

    NoMethodError: undefined method `abstract_class?’ for Object:Class

  17. Joachim Fornallaz on 20 Jul 21:41:

    @Ben Johnson I got this error too (with XXX == ApplicationController), but also other ones, which I cannot reproduce reliably, like SQLite3::BusyException and NoMethodError Exceptions from RESTful_ACL. This only happens on pages having images which are generated by Rails…

  18. Corky on 20 Jul 22:06:

    There’s an issue for me when I try to install on Win32 platform. It’s solved by modifying some files, instructions here – http://allaboutruby.wordpress.com/2009/07/20/installing-rails-on-windows-3-years-later/

  19. Josh Goebel on 20 Jul 22:18:

    I’m having a problem with array parameters in tests…

    http://pastie.org/552640

    Anyone else seeing this?

  20. Joachim Fornallaz on 20 Jul 22:34:

    All my problems disappear if I revert this commit: http://github.com/rails/rails/commit/bc2c4a45959be21e6314fba7876b32c1f04cd08a – I will a but eventually.

  21. Joachim Fornallaz on 20 Jul 22:38:

    I meant “file a bug”, sorry for the typo.

  22. Matt Jones on 20 Jul 23:49:

    @Corky – I posted a comment on your blog, but figured others here could use the info as well.

    The issue you saw with Gem.bin_path on Windows is a known issue with RubyGems, which has been fixed in trunk.

    Ref: http://rubyforge.org/tracker/index.php?func=detail&aid=26458&group_id=126&atid=575

  23. gif@live.cn on 21 Jul 01:44:

    Nice work! Thanks a lot.

  24. Ismael Marin on 21 Jul 02:06:

    Thank you very much guys for this great release.

  25. Andrey Prihodko on 21 Jul 05:43:

    I like bug fixes made! Hope they will help to avoid workarounds using.

  26. RailsGirl on 21 Jul 08:31:

    Pl. start blogging on Rails 3, and start up a website devoted to Rails 3 as discussed by Matt last month here, based on Uservoice requests.

    When are we getting BETA..? Actually how far are we from Rails 3…? What percentage level of completion is achieved so far from Dec 23rd to July 23rd ( almost 7 months )..? It would boost up our morals, with a short answer if possible.

    Pl. keep us updated on progress…

    Thanks

  27. Roderick van Domburg on 21 Jul 08:38:

    Thanks for the release. That was a heavy delivery…

  28. Wes Oldenbeuving on 21 Jul 09:29:

    Thanks for the new version. The AR::Base#to_xml changes look great!

  29. alan on 21 Jul 10:21:

    I dunno if “Thread-safety fixes for postgresql string quoting,” if right. Anyone care to response to my comments at http://github.com/rails/rails/commit/c5c022c705e4179f74e063186ea68a1c58797822#comment_25798 ?

  30. nuttapong.t on 21 Jul 11:29:

    Thank you for the release.

  31. Anton Jenkins on 21 Jul 12:54:

    Great work guys. Cheers!

  32. Jamie Hill on 21 Jul 15:02:

    Good to see 2.3 is still getting some attention.

    I’m still getting the following in certain circumstances:

    You have a nil object when you didn’t expect it! The error occurred while evaluating nil.call

    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/named_scope.rb:102

    As well as:

    can’t dup NilClass

    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb

  33. Jamie Hill on 21 Jul 15:03:

    Sorry, that last line should have been:

    /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:2184:in `dup’

  34. Andrea on 22 Jul 12:05:

    Yeah! Thanks guys…

  35. Ryan Lowe on 22 Jul 23:12:

    As far as I can tell this is the first version of Rails to require the Rack gem (by the actionpack gem). Seems like a change worthy of the release notes to me.

    If you clone Rails to vendor/rails from the source in the Rails GitHub repository like I do, you’ll also have to unpack the rack gem to vendor/gems to make your Rails project work properly.

  36. Thankful on 23 Jul 00:50:

    Awesome work Rails team. We appreciate the hard work that’s put into this.

    @dhh – Perhaps a blog post when you have a (spare, very spare) moment about how we can help with the transition to Rails 3 (documentation assistance, screencasts, quick how-to’s) – whatever is needed.

    Thanks again!

  37. Yuval on 23 Jul 21:25:

    Awesome work guys. Where can I find a full list of fixes? I see the default_scope/named_scope order bug is fixed, huzzah! :) But unordered validation messages are not. :( Just wondering what other goodies are in there. Cheers.

  38. Chris on 24 Jul 21:31:

    So 2.3.3 breaks existing apps that use the JSON gem by changing the behavior of to_json.

  39. rherrera on 26 Jul 02:04:

    Gracias, por el aporte, verdaderamente esta progresando la aplicacion, y verdaderamente necesitamos un libro mas adecuado con la actualizacion a la version 2.3

  40. bob on 29 Jul 03:20:

    Rails Rock