Skip to content

Instantly share code, notes, and snippets.

@firedev
Last active January 1, 2016 07:09
Show Gist options
  • Save firedev/8109910 to your computer and use it in GitHub Desktop.
Save firedev/8109910 to your computer and use it in GitHub Desktop.
Make Action Mailer use request host and protocol for images and links in emails.
# application_controller.rb
class ApplicationController < ActionController::Base
before_action :make_action_mailer_use_request_host_and_protocol
def make_action_mailer_use_request_host_and_protocol
ActionMailer::Base.default_url_options[:protocol] = request.protocol
ActionMailer::Base.default_url_options[:host] = request.host_with_port
ActionMailer::Base.asset_host = "#{request.protocol}#{request.host_with_port}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment