Skip to content

Commit

Permalink
Fix coupon URL in notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
phylor committed Jul 28, 2024
1 parent 7dbe4f1 commit bed209d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 2 additions & 5 deletions app/services/ops/coupon/expiration/notify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ module Ops
module Coupon
module Expiration
class Notify
include Rails.application.routes.url_helpers

attr_reader :coupon

delegate :user, to: :coupon
Expand All @@ -30,11 +28,10 @@ def template_options
"code" => coupon.code,
"description" => coupon.description,
"valid_until" => coupon.valid_until.present? ? I18n.l(coupon.valid_until) : "",
"url" => coupon_url(
"url" => Rails.application.routes.url_helpers.coupon_url(
user.locale,
coupon,
host: Rails.application.config.action_controller.default_url_options[:host],
port: Rails.application.config.action_controller.default_url_options[:port]
**Rails.application.config.action_controller.default_url_options
)
}
end
Expand Down
6 changes: 5 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ class Application < Rails::Application
I18n.available_locales = %i[en]
I18n.default_locale = :en

config.action_mailer.default_url_options = {host: ENV.fetch("HOST", "localhost"), port: 443}
config.action_mailer.default_url_options = {
host: ENV.fetch("HOST", "localhost"),
port: 443,
protocol: :https
}
config.action_controller.default_url_options = config.action_mailer.default_url_options
end
end
1 change: 1 addition & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@
config.action_controller.raise_on_missing_callback_actions = true

config.action_controller.default_url_options[:port] = 3000
config.action_controller.default_url_options[:protocol] = :http
end

0 comments on commit bed209d

Please sign in to comment.