Skip to content

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!

View the snippets archive ››

3 comments made

Ryan Bates commented on 03 Oct 07 at 15:39

I like to glance at the Reserved Words list on the wiki when picking names for models and attributes. This can help a lot in preventing tricky conflicts like this.

Michael @ SEOG commented on 11 Mar 08 at 01:41

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

PHP code sucks commented on 15 Jun 08 at 09:01

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

Got something to say?

About

Paul is a web developer for Kyanmedia web agency. He's lucky enough to write in Ruby on Rails full-time and uses this site to post snippets of code.

Contact

my name at gmail.com

More snippets

Take a look in the archive

Need a website?

Contact my employer. Make sure to check out our portfolio of work.

Hosting

I recommend hostingrails.com