Satchel
Satchel

Reputation: 16734

How to debug an wrong number of arguments (1 for 0) in Rails error?

I was trying to do some refactoring and messed things up but now don't know where or how to debug because it's not clear where the problem lies.

Some suggestions on how to dig into the error and code would be helpful...thanks!

http://gist.github.com/474290

Upvotes: 2

Views: 3562

Answers (2)

I don't know if it is relevant but this line looks weird:

<%= render :partial => "contact_event_list", 12: :locals => {:contact_event => contact_event, :event => event} %>

That "12:" in the middle, before :locals, looks out of place.

Upvotes: 0

tadman
tadman

Reputation: 211670

In this particular case you're probably calling .to_s on what you expect to be a DateTime but is in fact a nil:

datetime = DateTime.now
datetime.to_s(:default)
# => "2010-07-13T14:35:07-04:00"

datetime = nil
datetime.to_s(:default)
# => ArgumentError: wrong number of arguments (1 for 0)

If this is the case, either track down the missing date and populate it, or only render it if the date is present.

Upvotes: 5

Related Questions