Skip to content

Loading…

background_exception_notification doesn't seem to be searching in my app views #68

Closed
ejalbos opened this Issue · 4 comments

2 participants

@ejalbos

Using version 2.6.0 with rails 3.2.2, ruby 1.8.7.

Finally started using the background_exception_notification section and ran into an error where it looks like my custom section is not being found..
I am using my own custom section (from environment.rb):

      :sections => %w{instructions_for_support} + ExceptionNotifier::Notifier.default_sections,
      :background_sections => %w{instructions_for_support} + ExceptionNotifier::Notifier.default_background_sections
  }

(other parts are set elsewhere).

The instructions_for_support partial is being found just fine when I use the exception_notifier method, but it's not finding it when I use background_exception_notification. To investigate I renamed the partial so it wouldn't be found.

With exception_notification I get this message:

Missing partial exception_notifier/instructions_for_support with {:formats=>[:text], :locale=>[:en], :handlers=>[:coffee, :erb, :builder]}. Searched in:
    * "/home/bselig/.rvm/gems/ruby-1.8.7-p334@Upgrade32/gems/exception_notification-2.6.0/lib/exception_notifier/views"
    * "/mnt/dev_shared_codebase/Upgrade_Rails_32x/app/views"

and with background_exception_notification I get this error:

Missing partial exception_notifier/instructions_for_support with {:formats=>[:text], :locale=>[:en], :handlers=>[:coffee, :erb, :builder]}. Searched in:
  * "/home/bselig/.rvm/gems/ruby-1.8.7-p334@Upgrade32/gems/exception_notification-2.6.0/lib/exception_notifier/views"

As you can see, exception_notification is searching in my app's views folder while background_exception_notification is not.
The difference seems to be this line:

      self.append_view_path Rails.root.nil? ? "app/views" : "#{Rails.root}/app/views" if defined?(Rails)

which is at the beginning of exception_notification but not background_exception_notification.

Am I misunderstanding something or is this just an oversight in the code?

@ejalbos

NOTE: I was able to get this to work by following the soln here:
http://stackoverflow.com/questions/5389754/custom-partials-in-exception-notification-in-rails-3

Specifically, I added

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

into an initializer.

Is this the way it's supposed to be done or am I just masking an issue with the gem code (note that I did not have to do that with the regular notification, just when I started using the background notification)?

@smartinez87 smartinez87 was assigned
@smartinez87
Owner

@ejalbos just commited the fix for this issue. Please let me know if is good now. You shouldn't have to add that line to an initializer.
If you confirm this is fixed I'll release 2.6.1 with it.
Thanks!

@smartinez87 smartinez87 referenced this issue
Commit has since been removed from the repository and is no longer available.
@smartinez87 smartinez87 added a commit that referenced this issue
@smartinez87 Add entry for #68 on Changelog. ecc3aa9
@ejalbos

@smartinez87 - CONFIRMED

Just checked and it appears to work now.
I have the initializer line commented out and am doing a git reference in my Gemfile to get this latest code.

Now when I trigger the background notification it indeed finds the special section in my app/views.

Thx for the quick response.

As soon as 2.6.1 is released I'll reference it instead (hopefully soon as we have a release code freeze Monday, though I can workaround with that initializer line if need be).

Thx again (and thx for such a useful gem).

@smartinez87
Owner

@ejalbos just released 2.6.1.
Thanks for reporting the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.