Ruby on Rails种子db语法错误

时间:2015-03-31 02:51:46

标签: ruby-on-rails ruby

我正在尝试在rails应用程序中播放数据库,当我运行rake db:seed命令时,我一直收到此错误:

db / seeds.rb:3:语法错误,意外的tIDENTIFIER,期待')'              电子邮件:“example@projectman.net”

这是我的代码。请帮忙。

User.create!(first_name:  "Example",
             last_name: "User"
             email: "example@projectman.net",
             password:              "password",
             password_confirmation: "password")

9.times do |n|
  first_name  = Faker::Name.first_name
  last_name  = Faker::Name.last_name
  email = "example-#{n+1}@projectman.net"
  password = "password"
  User.create!(first_name:  first_name,
               last_name:   last_name,
               email: email,
               password:              password,
               password_confirmation: password)
end

1 个答案:

答案 0 :(得分:2)

你错过了一个逗号

User.create!(first_name:  "Example",
             last_name: "User"     <=== here
             email: "example@projectman.net",
             password:              "password",
             password_confirmation: "password")