我有这个输出哈希
output= {:user_id=>"1", :project_id=>"8", :task_id=>"87", :date=>"07/04/2017", :time_spent=>"1100", :comment=>"july 4th"}
我试图通过这样做将其保存到数据库中 Model.create!(输出)在模型中但不能保存它。我收到此错误
NoMethodError (undefined method `id' for nil:NilClass):
以下是服务器日志中显示的内容
SQL (0.3ms) INSERT INTO "entries" ("user_id", "project_id", "task_id", "date", "time_spent", "comment", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["user_id", 1], ["project_id", 8], ["task_id", 87], ["date", "2017-04-06 20:00:00.000000"], ["time_spent", "1100.0"], ["comment", "jully 4th"], ["created_at", "2017-07-04 10:57:30.040744"], ["updated_at", "2017-07-04 10:57:30.040744"]]
(0.2ms) ROLLBACK
Completed 500 Internal Server Error in 22ms (ActiveRecord: 6.4ms)
NoMethodError (undefined method `id' for nil:NilClass):
我无法弄清问题是什么。任何帮助将不胜感激