Remove turbo_stream views

Was barking up the wrong tree introducing these. The solution to the
issue of forms not re-rendering was to return the :unprocessable_entity
status when errors are encountered.
This commit is contained in:
Trevor Vallender 2023-08-19 16:41:01 +01:00
parent 107c2e62a8
commit 552935f5c7
5 changed files with 3 additions and 44 deletions

View File

@ -12,7 +12,7 @@ class SessionsController < ApplicationController
redirect_to @user, notice: t(".logged_in")
else
flash.now.alert = t(".login_fail")
render :new
render :new, status: :unprocessable_entity
end
end

View File

@ -14,7 +14,7 @@ class UsersController < ApplicationController
redirect_to root_path, notice: t(".account_created")
else
flash.now.alert = t(".create_failed")
render :new
render :new, status: :unprocessable_entity
end
end
@ -28,7 +28,7 @@ class UsersController < ApplicationController
redirect_to @user, notice: t(".account_updated")
else
flash.now.alert = t(".update_failed")
render :edit
render :edit, status: :unprocessable_entity
end
end

View File

@ -1,17 +0,0 @@
<% @title = "Log in" %>
<%= update_flash %>
<%= turbo_stream.replace "session_form" do %>
<%= form_with url: sessions_path, method: :post, id: "session_form" do |f| %>
<h2><%= t ".log_in" %></h2>
<%= f.label :username %>
<%= f.text_field :username %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.submit t(".log_in") %>
<% end %>
<% end %>

View File

@ -1,12 +0,0 @@
<% @title = "Edit account details" %>
<%= update_flash %>
<%= turbo_stream.replace "user_form" do %>
<%= render partial: "form",
locals: {
user: @user,
button_text: t(".edit"),
title: t(".edit"),
} %>
<% end %>

View File

@ -1,12 +0,0 @@
<% @title = "Register" %>
<%= update_flash %>
<%= turbo_stream.replace "user_form" do %>
<%= render partial: "form",
locals: {
user: @user,
button_text: t(".register"),
title: t(".register"),
} %>
<% end %>