Fix flashes display after grid introduction

Closes #5
This commit is contained in:
2024-01-17 21:57:18 +01:00
parent 11ecd8eaed
commit 1227c54e0e
5 changed files with 31 additions and 21 deletions

View File

@@ -47,6 +47,8 @@ class ApplicationController < ActionController::Base
def run_and_render(action)
send action
render 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'
end
end

View File

@@ -19,7 +19,7 @@ class UnitsController < ApplicationController
def create
@unit = current_user.units.new(unit_params)
if @unit.save
flash[:notice] = t(".success")
flash.now[:notice] = t(".success")
run_and_render :index
else
render :new
@@ -31,7 +31,7 @@ class UnitsController < ApplicationController
def update
if @unit.update(unit_params)
flash[:notice] = t(".success")
flash.now[:notice] = t(".success")
run_and_render :index
else
render :edit
@@ -40,7 +40,7 @@ class UnitsController < ApplicationController
def destroy
if @unit.destroy
flash[:notice] = t(".success")
flash.now[:notice] = t(".success")
end
run_and_render :index
end