在Rails开发中完成500内部服务器错误

问题描述 投票:0回答:1

开发我的Rails应用程序时,我已遇到此Completed 500 Internal Server Error。我正在关注开发的在线教程,并且以前运行良好。但是,从今天开始,如果我尝试渲染除正常的“是的,您在Rails上!”之外的页面,它将给我这个错误。页。

  Rendering messages/index.html.erb within layouts/application
  Rendered messages/index.html.erb within layouts/application (Duration: 0.6ms | Allocations: 199)
Completed 500 Internal Server Error in 19ms (ActiveRecord: 0.0ms | Allocations: 6751)

我已经在config / routes.rb中正确定义了我的路由(路由到messages#index,已经在app / controllers / message_controller.rb中定义了正确的控制器,并且已经为messages#index定义了正确的视图,但是它仍然一直给我这个错误。

日志仅包含上面的代码段,当我从Web上进行检查时,似乎没有任何有用的信息可供我调试。

感谢您的任何帮助,谢谢!

ruby-on-rails http-status-code-500
1个回答
0
投票

您仅附加了rails日志的最后三行。请附加更多日志。

这是打开'/ articles'页面时生成的日志的示例。

Started POST "/articles" for 127.0.0.1 at 2018-10-18 20:09:23 -0400
Processing by ArticlesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"XLveDrKzF1SwaiNRPTaMtkrsTzedtebPPkmxEFIU0ordLjICSnXsSNfrdMa4ccyBjuGwnnEiQhEoMN6H1Gtz3A==", "article"=>{"title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs.", "published"=>"0"}, "commit"=>"Create Article"}
New article: {"id"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs.", "published"=>false, "created_at"=>nil, "updated_at"=>nil}
Article should be valid: true
   (0.0ms)  begin transaction
  ↳ app/controllers/articles_controller.rb:31
  Article Create (0.5ms)  INSERT INTO "articles" ("title", "body", "published", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?)  [["title", "Debugging Rails"], ["body", "I'm learning how to print in logs."], ["published", 0], ["created_at", "2018-10-19 00:09:23.216549"], ["updated_at", "2018-10-19 00:09:23.216549"]]
  ↳ app/controllers/articles_controller.rb:31
   (2.3ms)  commit transaction
  ↳ app/controllers/articles_controller.rb:31
The article was saved and now the user is going to be redirected...
Redirected to http://localhost:3000/articles/1
Completed 302 Found in 4ms (ActiveRecord: 0.8ms)
© www.soinside.com 2019 - 2024. All rights reserved.