フォームに値を入力し、ボタンを押しても正常に動作しないことが発生した。
以下はフォーム入力し、ボタンを押下した後のログ
Started POST "/result" for ::1 at 2025-05-07 13:47:05 +0900
Processing by HomesController#result as TURBO_STREAM
Parameters: {"authenticity_token"=>"[FILTERED]", "content"=>{"word"=>"おはようございます"}, "commit"=>"変換"}
Rendering layout layouts/application.html.erb
Rendering homes/index.html.erb within layouts/application
Rendered homes/index.html.erb within layouts/application (Duration: 0.6ms | Allocations: 181)
Rendered layout layouts/application.html.erb (Duration: 44.4ms | Allocations: 1277)
Completed 200 OK in 64ms (Views: 46.1ms | ActiveRecord: 0.0ms | Allocations: 1896)
原因は2行目の「result as TURBO_STREAM」の部分だった。
turbo_streamで画面を動かしたい場合、Turbo_stream形式のファイル(result.turbo_stream.erb)を用意する必要がある
⇒それが存在せず、結果として何も返せていない状態
解決策として、TurboStreamを無効化した。
<%= form_with url: "/result", method: :post, model: @content, data: { turbo: false } do |f| %>
<%= f.text_area :word, placeholder: "ここに入力" %>
<%= f.submit "変換" %>
<% end %>
data: { turbo: false }を付け足すことで、正常に動作した。