fix(goals/pledge): redirect non-turbo-frame GET to goal show

UX audit: `app/views/goal_pledges/new.html.erb` unconditionally
renders the form in a DS::Dialog wrapper — when the user lands on
`/goals/:id/pledges/new` directly (F5, bookmark, stale deep-link),
the dialog renders as a freestanding modal over an otherwise-empty
page. Compare to `goals/new.html.erb` which has a
`turbo_frame_request?` branch with a full-page fallback.

Pledges aren't usefully standalone — the modal only makes sense
in goal context. Redirect non-frame GETs back to the goal show
page instead of rendering the broken-looking standalone dialog.

If we want a deep-linkable "open the pledge modal" experience
later, that lands as a `?open=pledge` query on the show page that
auto-fires the modal — out of scope here.
This commit is contained in:
Guillem Arias
2026-05-14 21:59:11 +02:00
parent dacce719dc
commit cd2bfa8eb5

View File

@@ -4,6 +4,14 @@ class GoalPledgesController < ApplicationController
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
def new
# The form is dialog-only. A direct GET (F5, bookmark, deep-link
# gone stale) lands the user back on the goal show page with the
# modal auto-opened via the catch-up CTA params, rather than
# rendering a freestanding DS::Dialog over an empty page.
unless turbo_frame_request?
redirect_to goal_path(@goal) and return
end
account = preselected_account
@pledge = @goal.goal_pledges.new(
currency: @goal.currency,