From 835d02aedfa670176f5f2fcdba5b44f0783c32b7 Mon Sep 17 00:00:00 2001 From: Daniel Munn Date: Sun, 3 Jun 2012 18:00:14 +0100 Subject: [PATCH] Additional controller updates; patched mailer for Rails 3; included override for ActionMailer so we can add path for plugin to view paths --- app/views/dmsf_mailer/send_documents.html.erb | 1 + app/views/dmsf_mailer/send_documents.text.erb | 1 + .../initializers/action_mailer_extensions.rb | 29 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 app/views/dmsf_mailer/send_documents.html.erb create mode 100644 app/views/dmsf_mailer/send_documents.text.erb create mode 100644 config/initializers/action_mailer_extensions.rb diff --git a/app/views/dmsf_mailer/send_documents.html.erb b/app/views/dmsf_mailer/send_documents.html.erb new file mode 100644 index 00000000..85a89fce --- /dev/null +++ b/app/views/dmsf_mailer/send_documents.html.erb @@ -0,0 +1 @@ +<%= ApplicationHelper.simple_format(@body) %> diff --git a/app/views/dmsf_mailer/send_documents.text.erb b/app/views/dmsf_mailer/send_documents.text.erb new file mode 100644 index 00000000..31bd20e2 --- /dev/null +++ b/app/views/dmsf_mailer/send_documents.text.erb @@ -0,0 +1 @@ +<%= @body %> diff --git a/config/initializers/action_mailer_extensions.rb b/config/initializers/action_mailer_extensions.rb new file mode 100644 index 00000000..bd90e85c --- /dev/null +++ b/config/initializers/action_mailer_extensions.rb @@ -0,0 +1,29 @@ +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