From bcf1aabd35b176ca29a45dcc4f0291780a2f27ea Mon Sep 17 00:00:00 2001 From: Ken Johnson Date: Thu, 11 Dec 2025 13:25:50 +0000 Subject: [PATCH 1/7] Add redirect for GET requests to /upload endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a redirect handler for users who try to access /upload via GET request instead of using the form POST. This prevents errors and guides users to the proper upload form. Changes: - Added GET route for /upload that redirects to benefit forms page - Added redirect_to_benefit_forms action in controller - Shows info flash message directing users to the upload form 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/controllers/benefit_forms_controller.rb | 5 +++++ config/routes.rb | 1 + 2 files changed, 6 insertions(+) diff --git a/app/controllers/benefit_forms_controller.rb b/app/controllers/benefit_forms_controller.rb index 1524cfc..4bcd246 100644 --- a/app/controllers/benefit_forms_controller.rb +++ b/app/controllers/benefit_forms_controller.rb @@ -16,6 +16,11 @@ class BenefitFormsController < ApplicationController end end + def redirect_to_benefit_forms + flash[:info] = "Please use the upload form below to upload files" + redirect_to user_benefit_forms_path(user_id: current_user.id) + end + def upload file = params[:benefits][:upload] diff --git a/config/routes.rb b/config/routes.rb index 497c0a1..99e5cda 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,6 +34,7 @@ Railsgoat::Application.routes.draw do end get "download" => "benefit_forms#download" + get "upload" => "benefit_forms#redirect_to_benefit_forms" post "upload" => "benefit_forms#upload" resources :tutorials do From 635d45d7908bd7e4d69238ad2c3b7bea73f8f004 Mon Sep 17 00:00:00 2001 From: Ken Johnson Date: Thu, 11 Dec 2025 13:29:05 +0000 Subject: [PATCH 2/7] Add local flash message display to benefit forms page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added flash message rendering directly on the benefit forms page to ensure upload feedback is always visible, even if the layout partial isn't rendering properly. This provides redundancy for flash messages and ensures users always see upload success/error feedback. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/views/benefit_forms/index.html.erb | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/app/views/benefit_forms/index.html.erb b/app/views/benefit_forms/index.html.erb index 5ae8a50..0934eda 100644 --- a/app/views/benefit_forms/index.html.erb +++ b/app/views/benefit_forms/index.html.erb @@ -1,4 +1,38 @@
+ + <% if flash.any? %> +
+
+ <% flash.each do |name, msg| %> + <% + alert_class = case name.to_sym + when :error, :alert then 'alert-danger' + when :success, :notice then 'alert-success' + when :info then 'alert-info' + when :warning then 'alert-warning' + else 'alert-secondary' + end + + icon_class = case name.to_sym + when :error, :alert then 'bi-exclamation-circle-fill' + when :success, :notice then 'bi-check-circle-fill' + when :info then 'bi-info-circle-fill' + when :warning then 'bi-exclamation-triangle-fill' + else 'bi-bell-fill' + end + %> + + <% end %> +
+
+ <% end %> +

From 004cf1e8635522341e19e10876fe0b9d91aff6a7 Mon Sep 17 00:00:00 2001 From: Ken Johnson Date: Thu, 11 Dec 2025 13:30:12 +0000 Subject: [PATCH 3/7] Fix flash.now messages not displaying in benefit forms view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed flash message check to include both flash and flash.now since error messages use flash.now when re-rendering without redirect. This ensures validation error messages display immediately when users upload invalid files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/views/benefit_forms/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/benefit_forms/index.html.erb b/app/views/benefit_forms/index.html.erb index 0934eda..4d42bce 100644 --- a/app/views/benefit_forms/index.html.erb +++ b/app/views/benefit_forms/index.html.erb @@ -1,9 +1,9 @@
- <% if flash.any? %> + <% if flash.any? || flash.now.any? %>
- <% flash.each do |name, msg| %> + <% (flash.to_hash.merge(flash.now.to_hash)).each do |name, msg| %> <% alert_class = case name.to_sym when :error, :alert then 'alert-danger' From 8c121cab6550a8ddad52cf53ad9f42b388e6bbce Mon Sep 17 00:00:00 2001 From: Ken Johnson Date: Thu, 11 Dec 2025 13:36:11 +0000 Subject: [PATCH 4/7] Fix undefined method error for flash.now by using to_hash.empty? --- app/views/benefit_forms/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/benefit_forms/index.html.erb b/app/views/benefit_forms/index.html.erb index 4d42bce..7d5a8d1 100644 --- a/app/views/benefit_forms/index.html.erb +++ b/app/views/benefit_forms/index.html.erb @@ -1,6 +1,6 @@
- <% if flash.any? || flash.now.any? %> + <% if flash.any? || !flash.now.to_hash.empty? %>
<% (flash.to_hash.merge(flash.now.to_hash)).each do |name, msg| %> From 6dc7ebac33620df9709da98373e5f67a5d20fa30 Mon Sep 17 00:00:00 2001 From: Ken Johnson Date: Thu, 11 Dec 2025 13:39:52 +0000 Subject: [PATCH 5/7] Simplify flash message handling - flash.each includes flash.now automatically --- app/views/benefit_forms/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/benefit_forms/index.html.erb b/app/views/benefit_forms/index.html.erb index 7d5a8d1..0934eda 100644 --- a/app/views/benefit_forms/index.html.erb +++ b/app/views/benefit_forms/index.html.erb @@ -1,9 +1,9 @@
- <% if flash.any? || !flash.now.to_hash.empty? %> + <% if flash.any? %>
- <% (flash.to_hash.merge(flash.now.to_hash)).each do |name, msg| %> + <% flash.each do |name, msg| %> <% alert_class = case name.to_sym when :error, :alert then 'alert-danger' From 3bd1fc24646196b930616143023ba2eb9e755bc1 Mon Sep 17 00:00:00 2001 From: Ken Johnson Date: Thu, 11 Dec 2025 13:42:21 +0000 Subject: [PATCH 6/7] Remove duplicate flash message rendering - layout already handles it --- app/views/benefit_forms/index.html.erb | 34 -------------------------- 1 file changed, 34 deletions(-) diff --git a/app/views/benefit_forms/index.html.erb b/app/views/benefit_forms/index.html.erb index 0934eda..5ae8a50 100644 --- a/app/views/benefit_forms/index.html.erb +++ b/app/views/benefit_forms/index.html.erb @@ -1,38 +1,4 @@
- - <% if flash.any? %> -
-
- <% flash.each do |name, msg| %> - <% - alert_class = case name.to_sym - when :error, :alert then 'alert-danger' - when :success, :notice then 'alert-success' - when :info then 'alert-info' - when :warning then 'alert-warning' - else 'alert-secondary' - end - - icon_class = case name.to_sym - when :error, :alert then 'bi-exclamation-circle-fill' - when :success, :notice then 'bi-check-circle-fill' - when :info then 'bi-info-circle-fill' - when :warning then 'bi-exclamation-triangle-fill' - else 'bi-bell-fill' - end - %> - - <% end %> -
-
- <% end %> -

From d8c48bec1f8dd2929ea9cc69831b00134280819b Mon Sep 17 00:00:00 2001 From: Ken Johnson Date: Thu, 11 Dec 2025 13:46:23 +0000 Subject: [PATCH 7/7] Remove fade class from flash messages to fix invisible alerts --- app/views/layouts/shared/_messages.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/shared/_messages.html.erb b/app/views/layouts/shared/_messages.html.erb index ea71b53..e95ec49 100755 --- a/app/views/layouts/shared/_messages.html.erb +++ b/app/views/layouts/shared/_messages.html.erb @@ -28,7 +28,7 @@ end %> -