Skip to content

Instantly share code, notes, and snippets.

@the-teacher
Created January 14, 2014 09:29
Show Gist options
  • Save the-teacher/8415623 to your computer and use it in GitHub Desktop.
Save the-teacher/8415623 to your computer and use it in GitHub Desktop.
config/initializers/action_mailer_extensions.rb:
module ActionMailer
class Base
class_inheritable_accessor :view_paths
def self.prepend_view_path(path)
view_paths.unshift(*path)
ActionView::TemplateFinder.process_view_paths(path)
end
def self.append_view_path(path)
view_paths.push(*path)
ActionView::TemplateFinder.process_view_paths(path)
end
private
def self.view_paths
@@view_paths ||= [template_root]
end
def view_paths
self.class.view_paths
end
def initialize_template_class(assigns)
ActionView::Base.new(view_paths, assigns, self)
end
end
end
You can do:
ActionMailer::Base.prepend_view_path('/my/other/path/to/search/first/')
# or
ActionMailer::Base.append_view_path('/my/other/path/to/search/last/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment