Custom partial notifications in exception notification in Rails 3

I am trying to configure a custom particle for exception notification messages in a Rails 3 application using the current version (2.4.0) exception_notification gem

README clearly states that "you can configure how each of these sections are displayed by placing a partial name for this part in your Application Catalog / views / exception _notifier [...] You can even add new sections that describe application-specific data "

And I'm definitely trying this: Modifying existing partitions and adding a new custom partition. When you just change the section, my modified partial (app / views / exception_notifier / _session.text.erb) does not affect. When I add a new custom section, I get the following error in the log:

ActionView::Template::Error (Missing partial exception_notifier/user with {:formats=> [:text], :handlers=>[:haml, :rjs, :rhtml, :builder, :erb, :rxml], :locale=>[:de]} in view paths "/usr/lib/ruby/gems/1.8/gems/exception_notification-2.4.0/lib/exception_notifier/views"): 

What am I doing wrong? I suspect that the viewing path was somehow confused and that exception_notifier did not bother to browse at all in the my / app / views / exception_notifier directory.

+4
source share
2 answers

When exception_notification is used as a gemstone, the only view_path parameter configured for the notifier is its own way of representing the gemstone. To override the default section template or add it yourself, you will have to add the application template folder to the view path.

Just add to your initializer

  ExceptionNotifier::Notifier.prepend_view_path File.join(Rails.root, 'app/views') 

If you have a partial partition, be sure to add it to the middleware options.

  Whatever::Application.config.middleware.use ExceptionNotifier, :email_prefix => "[Whatever] ", :sender_address => %{"notifier" < notifier@example.com >}, :exception_recipients => %w{ exceptions@example.com }, :sections => %w{my_section1 my_section2} + ExceptionNotifier::Notifier.default_sections 
+9
source

From version 2.6.0 of the gem and onward, this is no longer required. This error has already been fixed, so there is no need for this line on the initializer.

+2
source

Source: https://habr.com/ru/post/1344751/


All Articles