RailsでフォームやDBなどの機能を一通り実装して、簡単なブログサービスを作りました。
しかし、いざ用意したフォームから投稿しようとしたところ、ある程度短い文字列では正常に動くのですが、少しでも長くなると「We're sorry, but something went wrong.」と表示され機能しなくなってしまいます。
文字数としては650文字以上からエラーが吐かれるようです。ユーザーIDやタイトルなどの各種パラメータに加えて、markdownの本文、markdownをhtmlにパースした状態の本文をまとめてPOSTしています。
環境
- Rails 5.2.0
- nginx 1.12.2
- unicorn 5.4.0
ログの内容
nginxとunicorn側は特にエラーは吐いていないようでした。
以下Railsのログです。
正常時
Started GET "/dashboard/edit" for xxx.xxx.xxx.xxx at 2018-06-13 18:43:45 +0900 Processing by DashboardController#edit as HTML --- SQL --- ↳ app/controllers/application_controller.rb:7 Rendering XXXXXXXX Rendered XXXXXXXX Completed 200 OK in 39ms (Views: 32.4ms | ActiveRecord: 0.9ms) Started POST "/dashboard/edit/submit" for 175.184.118.251 at 2018-06-13 18:44:49 +0900 Processing by DashboardController#edit_submit as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"XXXX", "title"=>"XXXX", "content"=>"XXXX", "uid"=>"XXXX", "content_html"=>"<p>XXXX</p>\r\n"} --- SQL --- ↳ app/controllers/application_controller.rb:7 --- SQL --- ↳ app/controllers/dashboard_controller.rb:23 --- SQL(INSERT) --- ↳ app/controllers/dashboard_controller.rb:23 Redirected to XXXXXXX.XXX Completed 302 Found in 65ms (ActiveRecord: 18.6ms) Started GET "/dashboard" for XXX.XXX.XXX.XXX at 2018-06-13 18:44:45 +0900 Processing by DashboardController#home as HTML --- SQL --- ↳ app/controllers/application_controller.rb:7 Rendering XXXXXXXX Rendered XXXXXXXX Completed 200 OK in 50ms (Views: 39.9ms | ActiveRecord: 2.8ms)
失敗時
Started GET "/dashboard/edit" for xxx.xxx.xxx.xxx at 2018-06-13 18:43:45 +0900 Processing by DashboardController#edit as HTML --- SQL --- ↳ app/controllers/application_controller.rb:7 Rendering XXXXXXXXX Rendered XXXXXXXXX Completed 200 OK in 39ms (Views: 32.4ms | ActiveRecord: 0.9ms) Started GET "/dashboard" for xxx.xxx.xxx.xxx at 2018-06-13 18:44:45 +0900 --- SQL --- ↳ app/controllers/application_controller.rb:7 Rendering XXXXXXXXX Rendered XXXXXXXXX Completed 200 OK in 50ms (Views: 39.9ms | ActiveRecord: 2.8ms)
Railsのエラーログを見る限り、POSTリクエスト自体届いてないようにも思えます。
Rails以前の問題なのでしょうか?最近Railsに触れたばかりで初めて遭遇したバグなので解決への手がかりが掴めません。
何か知っている方がいらっしゃいましたら、ぜひご教授お願い致します。
##追記1
- 本文を挿入するカラムはtext型に設定しています。
##追記2
- Rails server で立てた状態では問題なくPOSTが完了し、nginx(SSL済)×unicornで立てた状態だと失敗するということが分かりました。nginxかunicornが悪さをしているのでしょうか...
回答1件
あなたの回答
tips
プレビュー