GLoc Validation Problems After Rails 2.1 Upgrade

by Matthias Marschall on August 28, 2008

http://www.agileweboperations.com/wp-content/plugins/sociofluid/images/digg_32.png http://www.agileweboperations.com/wp-content/plugins/sociofluid/images/stumbleupon_32.png http://www.agileweboperations.com/wp-content/plugins/sociofluid/images/delicious_32.png

When upgrading our application from Ruby on Rails 1.2.6 to Rails 2.1 we experienced some issues with the GLoc localization library.

First, we got exceptions like this one:

ActionView::TemplateError (wrong number of arguments (3 for 2))

Thanks to this Rails 2.1 patch for GLoc, we were able to run our application again.

But then we noticed the application threw exceptions on some validations. Here is such an exception:

NoMethodError (undefined method `%' for :error_invalid:Symbol):
   /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/validations.rb:695:in `validates_format_of'

As a workaround to solve the above exceptions, we added custom messages to the following validations:

validates_inclusion_of ..., :message => l(:incl_key)
validates_exclustion_of ..., :message => l(:excl_key)
validates_format_of ..., :message => l(:form_key)

Now, GLoc seems to work with Rails 2.1!

Share/Save/Bookmark

{ 1 comment… read it below or add one }

1 MonkeyPatcher 10.01.08 at 12:08 am

The good old Ruby on Rails “plugins”. Wait. Do they really call them plugins? Just patching framework classes at will doesn’t make this piece of code a plugin, does it? Long live the Monkey Patcher!!!

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>