Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 我无法使用更新方法的原因是什么?_Ruby On Rails_Ruby_Ruby On Rails 5 - Fatal编程技术网

Ruby on rails 我无法使用更新方法的原因是什么?

Ruby on rails 我无法使用更新方法的原因是什么?,ruby-on-rails,ruby,ruby-on-rails-5,Ruby On Rails,Ruby,Ruby On Rails 5,更新方法似乎不起作用,我得到以下错误: Started PATCH "/lessons/4" for 127.0.0.1 at 2017-07-20 11:23:27 +0900 Processing by LessonsController#update as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"+95AUkvSbAUfVzAp9xweeiuq8IKq3gdqJB5oP8HoRP3NvkoYHkGRYe1T

更新方法似乎不起作用,我得到以下错误:

Started PATCH "/lessons/4" for 127.0.0.1 at 2017-07-20 11:23:27 +0900
Processing by LessonsController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"+95AUkvSbAUfVzAp9xweeiuq8IKq3gdqJB5oP8HoRP3NvkoYHkGRYe1TQSMxVtTZGPlATx6ltb0SThD6ifMXpg==", "lesson"=>{"title"=>"まずはじめに", "content"=>"Jelly beans chupa chups soufflé toffee cookie croissant sugar plum cookie. Danish caramels gummi bears marzipan apple pie cupcake jelly pudding dragée. Jelly-o pastry halvah sweet. Pudding jujubes marshmallow pie soufflé. Tart chocolate bar dragée bonbon cotton candy jelly beans chupa chups. Cheesecake tart chupa chups candy canes sweet roll biscuit candy lollipop. Chupa chups lemon drops chocolate bear claw muffin tiramisu pastry marzipan ice cream. Sweet candy canes danish halvah caramels cupcake donut lemon drops gummi bears."}, "commit"=>"更新", "id"=>"4"}
  Lesson Load (0.1ms)  SELECT  "lessons".* FROM "lessons" WHERE "lessons"."id" = ? LIMIT ?  [["id", 4], ["LIMIT", 1]]
  User Load (0.2ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ?  [["id", 1], ["LIMIT", 1]]
No template found for LessonsController#update, rendering head :no_content
Completed 204 No Content in 112ms (ActiveRecord: 0.3ms)
我有一个课程模型和一个课程模型,我可以对我的课程模型使用更新方法,但不能对课程模型使用更新方法


有什么建议吗?

这对我来说很有效,如果它保存在DB中,希望它也能对您有所帮助

def update
 @lesson = Lesson.find(params[:id])
 if @lesson.update(params)
   redirect_to root_path, alert: "Your lesson is saved!"
 else
   render 'edit', alert: "Oops! There was a problem, please try again"
 end
end

这对我来说很有用,如果它保存在DB中,我希望它也能对你有用

def update
 @lesson = Lesson.find(params[:id])
 if @lesson.update(params)
   redirect_to root_path, alert: "Your lesson is saved!"
 else
   render 'edit', alert: "Oops! There was a problem, please try again"
 end
end

请上传LessonController,请上传LessonController,