I have a basic web app with a form using ActionText
. When changes are made, a have a Trix listener that calls my controller via AJAX (autosave!). The controller looks like this:
def update
respond_to do |format|
if @model.update(model_params)
format.json { render json: @model }
else
format.json { render json: @model.errors, status: :unprocessable_entity }
end
end
end
This was working absolutely fine on Rails 6.1 alpha, but since the update to Rails 6.1 RC1 the same code results in this error:
ActionView::MissingTemplate (Missing partial action_text/content/_layout with
{:locale=>[:en], :formats=>[:json], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby]}.
Is anyone able to shed any light on why this might be? I have tried digging through the source but I'm none the wiser. I wondered also whether it was related to this issue.
Thanks in advance.
I've solved this problem as follows. Originally I had format: :json
in the form_with
declaration:
<%= form_with(model: @model, format: :json) do |form| %>
This was working in Rails 6.1 Alpha but not in RC1. Removing the format from the code solved the issue.
<%= form_with(model: @model) do |form| %>
The POST request now comes through as JS not JSON and this makes the problem go away.
Processing by MyController#update as JS