Nightmares with datetime_select and the attr_locked plugin

| | Comments (0) | TrackBacks (0)

Yesterday, a co-worker had some growing pains when updating a Rails 1.2.3 application to Rails 2.1. I gladly came to the rescue (he actually saved me from a boring job) and we analyzed together what was the error we were getting on the app.


The thing happened to be on the form_helper method
datetime_select



A chunk of code (just like the one above) was throwing an exception that said:


ArgumentError: wrong number of arguments (1 for 2)


The exception was getting threw inside a method called
date_or_time_select
that was being invoked; inside the
datetime_select
method.

We checked out the plugins that could overwrite this method, and
attr_locked
was doing it via
alias_method_chain
. The problem was that, this overwrite didn't provide the correct number of parameters for the Rails 2.1 version (the Rails 2.1 version of
datetime_select
accepts an extra hash parameter called html_options). We made some little changes to the current implementation and it worked as expected.

Hope you can get some benefits from this patch

0 TrackBacks

Listed below are links to blogs that reference this entry: Nightmares with datetime_select and the attr_locked plugin.

TrackBack URL for this entry: http://www.hasmanydevelopers.com/cgi-bin/mt/mt-tb.cgi/7

Leave a comment

About this Entry

This page contains a single entry by Román González published on August 1, 2008 12:35 PM.

Just a mockup you say? was the previous entry in this blog.

Metting Merb and helping it to be even more cooler... is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.