Browse files

make compatible with rails ~> 3.0

  • Loading branch information...
1 parent 2696428 commit 9eb05f0b2e5bba51ab551bd4cdc254c17eba4e73 @nashby nashby committed Mar 25, 2013
Showing with 19 additions and 3 deletions.
  1. +16 −1 lib/mail_form/notifier.rb
  2. +3 −2 lib/mail_form/views/mail_form/contact.erb
View
17 lib/mail_form/notifier.rb
@@ -1,5 +1,20 @@
module MailForm
class Notifier < ActionMailer::Base
+ # since ActionMailer 3.0 has own simple_format method
+ # but we need one from the ActionPack
+ # https://github.com/rails/rails/commit/fb34f8577c47d958ca32b7ab585c1904e1a776b1
+ helper do
+ def simple_format(text, html_options={}, options={})
+ @text_helper ||= Class.new do
+ include ActionView::Helpers::TextHelper
+ include ActionView::Helpers::TagHelper
+ include ActionView::Helpers::SanitizeHelper
+ end.new
+
+ @text_helper.simple_format(text, html_options, options)
+ end
+ end
+
self.mailer_name = "mail_form"
append_view_path File.expand_path('../views', __FILE__)
@@ -22,4 +37,4 @@ def contact(resource)
mail(headers)
end
end
-end
+end
View
5 lib/mail_form/views/mail_form/contact.erb
@@ -22,8 +22,9 @@
value = @resource.request.send(attribute)
value = if value.is_a?(Hash) && !value.empty?
- list = value.to_a.map{ |k,v| content_tag(:li, h("#{k}: #{v.inspect}")) }.join("\n")
- content_tag(:ul, raw(list), :style => "list-style:none;")
+ content_tag(:ul, :style => "list-style:none;") do
+ value.to_a.map{ |k,v| content_tag(:li, h("#{k}: #{v.inspect}")) }.reduce{ |list, li| list << li << '\n'.html_safe }
+ end
elsif value.is_a?(String)
value
else

0 comments on commit 9eb05f0

Please sign in to comment.