Rails 3.2: ArgumentError: wrong number of arguments (2 for 1) on create

与世无争的帅哥 提交于 2019-12-05 03:16:11

Have you overloaded your model's initialize method? In my case, I had overloaded it with:

def initialize(attributes=nil)
    ...
end

Which I had to fix to:

def initialize(attributes = nil, options = {})
    ...
end

In Rails 3.2, the commit 7c5ae0a88fc9406857ee362c827c57eb23fd5f95 (Added mass-assignment security :as and :without_protection support to AR.new) added more arguments to the above method and that's why my previous implementation was failing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!