Wrong number of arguments (0 for 1) on notifiy method in Ruby on Rails

Posted on 02 October 2007

So I just got a cryptic error message: "Wrong number of arguments (0 for 1)" when using the check_box helper thus:

f.check_box :notify

Clearly I am providing the right number of arguments here. However, the problem lies with the notify method I have created. Observe...

script/console
Event.new.method :notify
=> #<Method: Event(ActiveRecord::Callbacks)#notify>

Turns out the notify method is already taken and is an ActiveRecord Call back. Doh!

About Paul

Paul works for Kyan web design agency in Surrey, UK as a Ruby on Rails developer.

Follow Paul on Twitter

Email: paulsturgess [at] gmail.com

Read more articles in the archive →

Comments...

  • I like to glance at the "Reserved Words":http://wiki.rubyonrails.org/rails/pages/ReservedWords list on the wiki when picking names for models and attributes. This can help a lot in preventing tricky conflicts like this.

    Ryan Bates at 03 Oct 07 at 15:39

  • Good tip Ryan, definitely a link to have handy when trying to track down funky errors!

    Michael @ SEOG at 11 Mar 08 at 01:41

  • Thanks for the debugging hint, never faced it yet, but worth noticing. Kif.

    PHP code sucks at 15 Jun 08 at 09:01

Got something to say?