ArgumentError:参数数量错误(0表示1)

时间:2011-02-27 19:52:02

标签: ruby-on-rails

我正在尝试测试在sqlite3 db中插入一行,对于第7章中的Rails教程。我已经多次查看代码并且它看起来是正确的,但是在控制台中我收到以下错误。有什么建议?

  
    

User.create(name =>“test user”,:email =>“testuser@example.com”,:password =>“foobar”,:password_confirmation =>“foobar”)     ArgumentError:参数数量错误(0表示1)         来自/Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:442:in maximum' from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:442:in 发送'         from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:442:in maximum' from /Users/gabemcmillan/rails_projects/sample_app/app/models/user.rb:10 from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:454:in load'         from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:454:in load_file' from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in new_constants_in'         from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:453:in load_file' from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:340:in require_or_load'         from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:491:in load_missing_constant' from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:183:in const_missing'         from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:181:in each' from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:181:in const_missing'         来自(irb):8

  

1 个答案:

答案 0 :(得分:3)

应为User.create(:name...name之前有冒号),而不是User.create(name...