diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 11cd51e..6956a31 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,4 +1,11 @@ class ApplicationController < ActionController::Base + # Turbo-rails disables layout rendering for turbo_frame requests (i.e. + # requests that specify 'turbo-frame:' header). + # As a side effect, this also disables layout for turbo_stream requests that + # happen to originate from within turbo frame (e.g. turbo_frame_tag or tag + # with 'is="turbo-frame"' attribute). To fix this, either frame tags must not be + # used, or custom layout method needs to be defined. + helper_method :current_user_disguised? before_action :authenticate_user! @@ -47,8 +54,6 @@ class ApplicationController < ActionController::Base def run_and_render(action) send action - # 2024-01-17, Rails 7.1.2: For unknown reason turbo_stream layout is omitted - # during render on POST method only (GET, DESTROY are ok). - render action, layout: 'application' + render action end end diff --git a/app/views/units/edit.turbo_stream.erb b/app/views/units/edit.turbo_stream.erb index b796499..d3c8bee 100644 --- a/app/views/units/edit.turbo_stream.erb +++ b/app/views/units/edit.turbo_stream.erb @@ -1,5 +1,4 @@ -<%# TODO: make sure turbo_stream layout is used in new/edit %> -<%= turbo_stream.update :unit_form_frame do %> +<%= turbo_stream.replace :unit_form do %> <%= form_with model: @unit, html: {id: :unit_form} do %> <% end %> <% end %> diff --git a/app/views/units/index.html.erb b/app/views/units/index.html.erb index 143aac8..5ebd3e6 100644 --- a/app/views/units/index.html.erb +++ b/app/views/units/index.html.erb @@ -1,13 +1,11 @@