作者:爱做梦的蓝梦 | 来源:互联网 | 2023-09-04 11:47
Usingdeviceandcantcreatetaskmymodelsuser使用设备并不能创建我的模型用户任务classUser<ApplicationReco
Using device and can't create task my models user
使用设备并不能创建我的模型用户任务
class User
task
class Task
task controller
def create
@task = Task.new(task_params)
respond_to do |format|
if @task.save
format.html { redirect_to @task, notice: 'Task was successfully created.' }
format.json { render :show, status: :created, location: @task }
else
format.html { render :new }
format.json { render json: @task.errors, status: :unprocessable_entity }
end
end
end
and when trying to create task have an error
并且在尝试创建任务时出错
1 error prohibited this task from being saved:
1错误禁止保存此任务:
User must exist
my response
Started POST "/tasks" for 127.0.0.1 at 2017-12-27 14:20:59 +0200 Processing by TasksController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"b7EkQsJygYBW1xLIm1uFD8jluXy2LYeoYjAOjKcwWOMHLwtalXmkTrNJu0yhexucwY94COegDcuVrOWLRkf8dg==", "task"=>{"title"=>"", "description"=>"", "priority"=>"", "due(1i)"=>"2017", "due(2i)"=>"12", "due(3i)"=>"27", "done"=>"0"}, "commit"=>"Create Task"}
在2017-12-27 14:20:59开始POST“/ tasks”为127.0.0.1 +0200由TasksController处理#create as HTML参数:{“utf8”=>“✓”,“authenticity_token”=>“b7EkQsJygYBW1xLIm1uFD8jluXy2LYeoYjAOjKcwWOMHLwtalXmkTrNJu0yhexucwY94COegDcuVrOWLRkf8dg = =“,”“task”=> {“title”=>“”,“description”=>“”,“priority”=>“”,“due(1i)”=>“2017”,“due(2i) “=>”12“,”due(3i)“=>”27“,”完成“=>”0“},”提交“=>”创建任务“}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 2], ["LIMIT", 1]]
(0.0ms) begin transaction
(0.1ms) rollback transaction
what's wrong?
4 个解决方案