Release: UJS Rails Plugin 0.3.1

Fresh out of Textmate, as Dan would say, is UJS Rails Plugin 0.3.1. Don’t be fooled by the point release; this release contains no new functionality but some important bug fixes.

There are two major fixes in this release. The first is that the module name that was used throughout much of the source code has been changed from UnobtrusiveJavascript to UJS. This change, as I mentioned in a previous post means that UJS is now compatible with Edge Rails. There was one change to the API as a result. In your routes.rb file, change the following line:


UnobtrusiveJavascript::routes

To this:


UJS::routes

The other biggest fix is an issue that both Dan and I have observed in production apps we are working on that use UJS. For some reason, on a server restart, the server would mysteriously hang, with no apparent error being logged. We eventually traced the problem down to serializing our own BehaviourScript class to the session (early releases of UJS just used a hash) with Rails being unable to find the class when loading the class from the session on server restart. The problem was fixed by converting BehaviourScript objects to hashes before session storage. All reports seem good so far; this does appear to have fixed the problem. If you are still seeing some strange issues, please file a bug on Trac.

As well as the above, there are also some other small fixes. Thanks to everybody who filed bugs in Trac. Here is the complete changelog:

  • FIXED: Issues with Rails edge have now been resolved. Have changed the UnobtrusiveJavascript module to UJS. This has one API change – use UJS::Routes in routes.rb
  • FIXED: Major issue when restarting server (server just hangs) due to serializing of behaviour scripts to the session. Objects are now converted to and from a hash before serializing to the session. All reports suggest that this has fixed the issue. Please raise a ticket if you get any more weird errors.
  • FIXED: remote_function was incorrectly quoting JS (ticket #3)
  • FIXED: :external => false now works for apply_behaviours (ticket #5)
  • FIXED: element.replace_html inside Ruby behaviour block wasn’t working, this is now fixed (ticket #4)
  • FIXED: behaviours_url now works correctly when using mongrel url-prefix (ticket #6)
  • FIXED: Resolved some documentation issues

The API docs have also been updated. If you are using the “current” tag all you need to do is run an svn up, otherwise the new release can be found at http://source.ujs4rails.com/tags/rel-0.3.1.

Return to home page

1 Comments on this article

1. Comment by Rob on 05 Sep 2006 at 06:09

To get my app working after installing UJS 0.3.1, I had to clear out old sessions as they contained the old ‘UnobtrusiveJavascript’ module name.
You can clear sessions with this rake command:
rake tmp:sessions:clear
The error in my log before I cleared old sessions looked like this:
Session contains objects whose class definition isn’t available.
Remember to require the classes for all objects kept in the session.
(Original exception: uninitialized constant UnobtrusiveJavascript [NameError])
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/cgi_process.rb:148:in `stale_session_check!’
...

Return to home page

Have your say