Use helper to update flash in streams

This commit is contained in:
Trevor Vallender 2023-08-18 21:02:39 +01:00
parent db908d4ea4
commit c57fe587c2
4 changed files with 12 additions and 9 deletions

View File

@ -8,4 +8,10 @@ module ApplicationHelper
def current_user
@current_user ||= User.find(session[:user_id]) if logged_in?
end
def update_flash
turbo_stream.replace "flash_wrapper" do
render "shared/flash"
end
end
end

View File

@ -1,7 +1,6 @@
<% @title = "Log in" %>
<%= turbo_stream.replace "flash_wrapper" do %>
<%= render "shared/flash" %>
<% end %>
<%= update_flash %>
<%= turbo_stream.replace "session_form" do %>
<%= form_with url: sessions_path, method: :post, id: "session_form" do |f| %>

View File

@ -1,7 +1,6 @@
<% @title = "Edit account details" %>
<%= turbo_stream.replace "flash_wrapper" do %>
<%= render "shared/flash" %>
<% end %>
<%= update_flash %>
<%= turbo_stream.replace "user_form" do %>
<%= render partial: "form",

View File

@ -1,7 +1,6 @@
<% @title = "Register" %>
<%= turbo_stream.replace "flash_wrapper" do %>
<%= render "shared/flash" %>
<% end %>
<%= update_flash %>
<%= turbo_stream.replace "user_form" do %>
<%= render partial: "form",