So for those getting a message like this, the basic answer to the, "why am I getting this error?" question is that somewhere you're specifying the wrong number of arguments to a method, no matter how obscure or wrong you think that is - it's almost definitely a typo in your code somewhere. Below is just one case that I ran into.
I've got a functional test that errors on the following method, saying that the first "Quality.create!(..." statement has too many arguments, which doesn't make any sense to me at all.
Running Ruby 1.8, Rails 2.3.5
def reset_quality_lut
Quality.delete_all
Quality.create!(:value => 1, :name => "Scrap", :extended_name => " (only good for parts)" )
Quality.create!(:value => 2, :name => "Heavy use", :extended_name => " (needs work)" )
Quality.create!(:value => 3, :name => "Medium use", :extended_name => " (some functional damage)")
Quality.create!(:value => 4, :name => "Light use", :extended_name => " (cosmetic damage only)" )
Quality.create!(:value => 5, :name => "New", :extended_name => " (or like new)" )
Quality.create!(:value => 0, :name => "Any", :extended_name => "/all" )
end
What the method is supposed to do is delete, and then re-create all the values in this table.
Here is the requested stack trace (note that I get the same thing if I replace the '.create' with a '.new(....).save':
1) Error:
test_should_create_an_admin_user_on开发者_开发问答_app_setup(SetupControllerTest):
ArgumentError: wrong number of arguments (1 for 0)
app/controllers/setup_controller.rb:43:in `reset_quality_lut'
app/controllers/setup_controller.rb:23:in `create'
/test/functional/setup_controller_test.rb:78:in `test_should_create_an_admin_user'
In the app, what this controller does is let you setup the app after initial setup. So...
www.myapp.com/setup/new
Brings you to a page where you enter a username and password for the first admin. When this succeeds, this action becomes inaccessible, so long as there's 1 admin user in the database.
EDIT: If I try "Quality.new.save", I get a nil error. Seems my "new" method is returning nil for some strange reason.
The create!
method should certainly work normally as you've used it. Is there any possibility that something else has defined a create!
method on the Quality
class? Or indeed on all model classes.
Either that or there may be a conflict between two Quality
classes (I'm taking it as read that your Quality
class is an ActiveRecord::Base
subclass).
精彩评论