Skip to content

Change ActionMailer::Base.default_url_options on runtime #66

@mattherick

Description

@mattherick

Hi!

I have a problem with changing the ActionMailer::Base.default_url_options = {:host => host} on runtime.

My environment

rails (4.2.0)
sidekiq (3.3.1)
devise (3.4.1)
devise-async (0.9.0)

I have a before_action in my application_controller

class ApplicationController < ActionController::Base

  before_action :set_action_mailer_default_url_options

  private

  def set_action_mailer_default_url_options
    host = "some-logic-to-get-the-correct-host
    ActionMailer::Base.default_url_options = {:host => host}
  end

end

Now if I want to reset my password I always get the default url options, which I have specified in the environments file. If I remove the default_url_options from my environments I get an error in my sidekiq logs.

ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true

The host is always set correctly in the controller. I already debugged that. It seems that the host is not passed to sidekiq.. any idea how I can fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions