Exception Notification Gem and Rails 3

后端 未结 17 2047
野趣味
野趣味 2021-01-30 05:16

I\'m trying to get this up and running, but I see \"uninitialized constant ExceptionNotifier\" whenever I start my server.

http://github.com/rails/exception_notificatio

相关标签:
17条回答
  • 2021-01-30 05:55

    Using Rails 3.0.3 this works for me:

    gem "exception_notification", :git => "https://github.com/sickill/exception_notification.git", :require => 'exception_notifier'
    

    :git part is imported because its a patched version to get around the 'undefined method controller_name error' and :require to require the right lib.

    Then in my production.rb environment file i only have this (from the manual)

      config.middleware.use ExceptionNotifier,
        :email_prefix => "[MyApp] ",
        :sender_address => %{"notifier" <email@example.com>},
        :exception_recipients => %w{email@example.com}
    

    Seems like there are many different ways to get this to work, but this was my way.

    Cheers!

    0 讨论(0)
  • 2021-01-30 05:57

    https://github.com/smartinez87/exception_notification

    This gem has been updated for rails 3.x and I just tested on 3.0.7 and the installation is much simpler.

    Gemfile:

    gem 'exception_notification'
    

    Initializer:

    Rails.application.config.middleware.use ExceptionNotifier,
      :email_prefix => "[Whatever] ",
      :sender_address => %{"notifier" <notifier@example.com>},
      :exception_recipients => %w{exceptions@example.com}
    
    0 讨论(0)
  • 2021-01-30 05:58

    Ok, its working now for me:

    # Gemfile
    gem "exception_notification", :git => "git://github.com/rails/exception_notification", :require => 'exception_notifier'
    
    # application.rb, inside the config block
    config.middleware.use ::ExceptionNotifier,
      :email_prefix => "ApplicationName-Errors: ",
      :sender_address => %w{office@application.com},
      :exception_recipients => %w{office@application.com}
    
    0 讨论(0)
  • 2021-01-30 05:58

    UPDATED ANSWER as of 3/14...

    You just need to do gem exception_notification in your gem file. No 'require' needed.

    Also, other changes just straight from the docs...

    "As of 4.x version the configuration syntax has changed. All email related options MUST BE nested under the :email key."

    like so...

    Whatever::Application.config.middleware.use ExceptionNotification::Rack,
      :email => {
        :email_prefix => "[Whatever] ",
        :sender_address => %{"notifier" <notifier@example.com>},
        :exception_recipients => %w{exceptions@example.com}
      }
    
    0 讨论(0)
  • The official repo on github is now: https://github.com/smartinez87/exception_notification

    In the Gemfile

    gem "exception_notification", :require => 'exception_notifier', :git => "https://github.com/smartinez87/exception_notification.git"
    

    In config\initializers\exception_notification.rb

    Rails.application.config.middleware.use ExceptionNotifier,
      :email_prefix => "[Whatever] ",
      :sender_address => %{"notifier" <notifier@example.com>},
      :exception_recipients => %w{exceptions@example.com}  
    
    0 讨论(0)
  • 2021-01-30 06:01

    I copied and pasted the exception_notification config from old app to new one and it failed. It brought me here and none of the above answers were up-to-date. Since 4.x version the middleware was renamed to ExceptionNotification::Rack, so middleware config looks like that:

    Whatever::Application.config.middleware.use ExceptionNotification::Rack,
     :email => {
       :email_prefix => "[Whatever] ",
       :sender_address => %{"notifier" <notifier@example.com>},
       :exception_recipients => %w{exceptions@example.com}
     }
    
    0 讨论(0)
提交回复
热议问题