Ruby On Rails:创建一个新记录会出现错误:语法错误,意外',',期望输入结束

时间:2017-02-25 21:51:46

标签: ruby-on-rails-5 rails-console

我正在苦苦寻找这个陈述我出错的地方 我使用相同的语法在我的数据库中创建其他记录 但是我没有使用=>的问题或逗号直到现在。

Loading development environment (Rails 5.0.1)
irb(main):006:0> me = AdminUser.create (:first_name => "test", :last_name => "user", :username => "tuser")

SyntaxError: (irb):1: syntax error, unexpected =>, expecting ')'
...dminUser.create (:first_name => "test", :last_name => "user"...
...                               ^
(irb):1: syntax error, unexpected ',', expecting end-of-input
....create (:first_name => "test", :last_name => "user", :usern...
...                               ^
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/console.rb:65:in `start'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/console_helper.rb:9:in `start'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:78:in `console'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'
irb(main):002:0>

1 个答案:

答案 0 :(得分:2)

你有一个额外的空间

me = AdminUser.create(:first_name =&gt;“test”,:last_name =&gt;“user”,:username =&gt;“tuser”)