From 65d60e2551b6a5341c55e704629ccbe047847b6c Mon Sep 17 00:00:00 2001 From: Luke Oldenburg <87272260+Luke-Oldenburg@users.noreply.github.com> Date: Sun, 7 Dec 2025 02:30:13 +0000 Subject: [PATCH 1/4] Add migration --- app/models/referral/program.rb | 1 + .../20251207022849_add_redirect_to_to_referral_programs.rb | 5 +++++ db/schema.rb | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20251207022849_add_redirect_to_to_referral_programs.rb diff --git a/app/models/referral/program.rb b/app/models/referral/program.rb index 4362971937..f4a33b717d 100644 --- a/app/models/referral/program.rb +++ b/app/models/referral/program.rb @@ -10,6 +10,7 @@ # login_header_text :string # login_text_color :string # name :string not null +# redirect_to :string # created_at :datetime not null # updated_at :datetime not null # creator_id :bigint diff --git a/db/migrate/20251207022849_add_redirect_to_to_referral_programs.rb b/db/migrate/20251207022849_add_redirect_to_to_referral_programs.rb new file mode 100644 index 0000000000..3b4f2b5507 --- /dev/null +++ b/db/migrate/20251207022849_add_redirect_to_to_referral_programs.rb @@ -0,0 +1,5 @@ +class AddRedirectToToReferralPrograms < ActiveRecord::Migration[8.0] + def change + add_column :referral_programs, :redirect_to, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 4b44024cc9..2c342585d6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,7 +12,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_12_05_035167) do +ActiveRecord::Schema[8.0].define(version: 2025_12_07_022849) do create_schema "google_sheets" # These are extensions that must be enabled in order to support this database @@ -2010,6 +2010,7 @@ t.string "login_header_text" t.string "login_text_color" t.string "name", null: false + t.string "redirect_to" t.datetime "updated_at", null: false t.index ["creator_id"], name: "index_referral_programs_on_creator_id" end From f20346ebff8eb183d437b96e7dead8aec52f55ba Mon Sep 17 00:00:00 2001 From: Luke Oldenburg <87272260+Luke-Oldenburg@users.noreply.github.com> Date: Sun, 7 Dec 2025 02:39:22 +0000 Subject: [PATCH 2/4] Add UI and controller --- app/controllers/admin_controller.rb | 2 +- app/controllers/referral/links_controller.rb | 2 +- app/views/admin/referral_programs.html.erb | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 86085a4246..147f82e041 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1407,7 +1407,7 @@ def referral_programs end def referral_program_create - @referral_program = Referral::Program.new(name: params[:name], creator: current_user) + @referral_program = Referral::Program.new(name: params[:name], redirect_to: params[:redirect_to], creator: current_user) if @referral_program.save flash[:success] = "Referral program created successfully." diff --git a/app/controllers/referral/links_controller.rb b/app/controllers/referral/links_controller.rb index 5d886033fd..b3aa339c3b 100644 --- a/app/controllers/referral/links_controller.rb +++ b/app/controllers/referral/links_controller.rb @@ -21,7 +21,7 @@ def show skip_authorization end - redirect_to params[:return_to] || root_path + redirect_to @link.program.redirect_to.presence || root_path, allow_other_host: true end private diff --git a/app/views/admin/referral_programs.html.erb b/app/views/admin/referral_programs.html.erb index 07ebd95794..6a5f3e0830 100644 --- a/app/views/admin/referral_programs.html.erb +++ b/app/views/admin/referral_programs.html.erb @@ -8,6 +8,7 @@