Trying to create an instance of a model, I get the following error...
u = User.create
# or .where(...).first_or_create
# or .where(...).first_or_initialize
ArgumentError: wrong number of arguments (2 for 1)
Is anyone having the same problem with Rails 3.2?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With