Use helper to update flash in streams
This commit is contained in:
parent
db908d4ea4
commit
c57fe587c2
|
@ -8,4 +8,10 @@ module ApplicationHelper
|
||||||
def current_user
|
def current_user
|
||||||
@current_user ||= User.find(session[:user_id]) if logged_in?
|
@current_user ||= User.find(session[:user_id]) if logged_in?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_flash
|
||||||
|
turbo_stream.replace "flash_wrapper" do
|
||||||
|
render "shared/flash"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<% @title = "Log in" %>
|
<% @title = "Log in" %>
|
||||||
<%= turbo_stream.replace "flash_wrapper" do %>
|
|
||||||
<%= render "shared/flash" %>
|
<%= update_flash %>
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= turbo_stream.replace "session_form" do %>
|
<%= turbo_stream.replace "session_form" do %>
|
||||||
<%= form_with url: sessions_path, method: :post, id: "session_form" do |f| %>
|
<%= form_with url: sessions_path, method: :post, id: "session_form" do |f| %>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<% @title = "Edit account details" %>
|
<% @title = "Edit account details" %>
|
||||||
<%= turbo_stream.replace "flash_wrapper" do %>
|
|
||||||
<%= render "shared/flash" %>
|
<%= update_flash %>
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= turbo_stream.replace "user_form" do %>
|
<%= turbo_stream.replace "user_form" do %>
|
||||||
<%= render partial: "form",
|
<%= render partial: "form",
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<% @title = "Register" %>
|
<% @title = "Register" %>
|
||||||
<%= turbo_stream.replace "flash_wrapper" do %>
|
|
||||||
<%= render "shared/flash" %>
|
<%= update_flash %>
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= turbo_stream.replace "user_form" do %>
|
<%= turbo_stream.replace "user_form" do %>
|
||||||
<%= render partial: "form",
|
<%= render partial: "form",
|
||||||
|
|
Loading…
Reference in New Issue