Sha256: e7c4a45ea82be1799ed7a96b84c7890b2701fbd9a73a5ffdb9e8266de95ec2a2

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

module ActionMailerWithRequest

  module ControllerMixin

    def self.included(base)
      base.class_eval do
        before_filter :store_request
      end
    end

    def store_request
      Thread.current[:request] = request
    end

  end

  module MailerDefaultUrlOptions

    def self.included(base)
      base.class_eval do
        def default_url_options_with_current_request
          host = Thread.current[:request].try(:host)
          port = Thread.current[:request].try(:port)
          default = {}
          default[:host] = host if host
          default[:port] = port if port and port != 80
          default_url_options_without_current_request.merge(default)
        end
        alias_method_chain :default_url_options, :current_request
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
actionmailer-with-request-0.1.0 lib/actionmailer_with_request.rb