ruby-on-railsturbo

How to debug rails to step through process of generating accept headers


Launching an action, the browser provide information on the accept headers, which in this probematic case renders: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 when the desired effect if to have turbo inject text/vnd.turbo-stream.html in that place.

However, debugging this has a challenge. Using, on rails 7.1 binding.break at the very beginning of processing by the application_controller

Started POST "/ops/aggregate_items?id=23" for ::1 at 2024-05-30 10:17:22 +0200
Processing by OpsController#aggregate_items as HTML
     5|   before_action :set_clean_host_site
[...]
     8|   def set_clean_host_site
=>   9|  binding.break

the processing format has already been set.

How can one step through that process rails has gone through to determine the processing method
(then I assume I can identify the motive for the unexpected behaviour) ?

where <%= form_with url: aggregate_items_ops_path(id: main_container_item.id), data: { turbo: true, format: :turbo_stream } do |form| %> is rendering

<form data-turbo="true" data-format="turbo_stream" action="/ops/aggregate_items?id=23" accept-charset="UTF-8" method="post">

but still being interpreted as HTML processing.


Solution

  • This answer may appear very curious, but it is reproducible (albeit difficult to do so).

    The issue observed was one of system memory (probably overflow).
    The way it can be intercepted is by

    If after invoking a reload of the console and the error is still invaried, system memory is shot.

    Solution:
    Restart computer.