ruby on rails - "Wrong number of arguments (1 for 0)" in the "create" action -
so getting message this, basic answer the, "why getting error?" question somewhere you're specifying wrong number of arguments method, no matter how obscure or wrong think - it's typo in code somewhere. below 1 case ran into.
i've got functional test errors on following method, saying first "quality.create!(..." statement has many arguments, doesn't make sense me @ 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 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 new)" ) quality.create!(:value => 0, :name => "any", :extended_name => "/all" ) end
what method supposed delete, , re-create values in table.
here requested stack trace (note same thing if replace '.create' '.new(....).save':
1) error: test_should_create_an_admin_user_on_app_setup(setupcontrollertest): argumenterror: wrong number of arguments (1 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 app, controller let setup app after initial setup. so...
www.myapp.com/setup/new
brings page enter username , password first admin. when succeeds, action becomes inaccessible, long there's 1 admin user in database.
edit: if try "quality.new.save", nil error. seems "new" method returning nil strange reason.
the create!
method should work you've used it. there possibility else has defined create!
method on quality
class? or indeed on model classes.
either or there may conflict between 2 quality
classes (i'm taking read quality
class activerecord::base
subclass).
Comments
Post a Comment