简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM