perf+ux(goals): grouped state-count + friendly 404 for stale/cross-family deep links

- index: STATE_FILTERS count loop replaced with single Current.family.goals.group(:state).count + per-state lookup. 5 SQL queries -> 1.
- GoalsController + GoalContributionsController: rescue_from ActiveRecord::RecordNotFound -> redirect_to goals_path with a flash. Affects stale deep links AND cross-family access (previously bare 404 -> Chrome error page). Test for cross-family access updated to assert the redirect + flash key.
- New locale key goals.errors.not_found.
This commit is contained in:
Guillem Arias
2026-05-11 20:19:00 +02:00
parent 9b61e4a41b
commit c018f95dfa
4 changed files with 16 additions and 2 deletions

View File

@@ -141,6 +141,7 @@ class GoalsControllerTest < ActionDispatch::IntegrationTest
other_goal.save!
get goal_url(other_goal)
assert_response :not_found
assert_redirected_to goals_path
assert_equal I18n.t("goals.errors.not_found"), flash[:alert]
end
end