LoginSignup
6
7

More than 5 years have passed since last update.

Rails4.0.0.rc1 exception_notificationエラー

Posted at

エラーメッセージ

rails s
----------
/Users/shu/.rbenv/versions/2.0.0-p195/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0.rc1/lib/active_support/core_ext/class/attribute_accessors.rb:40:in `block in cattr_reader': invalid class attribute name: true (NameError)
----------

対処

exception_notification v4.0.0がおそらくRails4.0対応版になると思われる、現在はGitHubのmasterブランチを直接指定する

Gemfile

gem 'exception_notification', github: 'smartinez87/exception_notification'

config/initializers/exception_notification.rb

AppName::Application.config.middleware.use(
  ExceptionNotifier,
  email_prefix:         "[#{Rails.env}][Site Name] ",
  sender_address:       "xxxxx@gmail.com",
  exception_recipients: ["xxxxx@gmail.com"]
)

config/environments/development.rb

  # メール設定
  config.action_mailer.default_url_options   = { host: '0.0.0.0:3000' }
  config.action_mailer.delivery_method       = :smtp
  config.action_mailer.perform_deliveries    = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.smtp_settings         = {
    address:              "smtp.gmail.com",
    port:                 587,
    user_name:            "xxxxx@gmail.com",
    password:             "xxxxxxxxxx",
    authentication:       'plain',
    enable_starttls_auto: true,
  }
  • 手動送信
    begin
      raise
    rescue Exception => exception
      ExceptionNotifier.notify_exception(exception, env: request.env, data: { msg: "エラーテスト" })
    end
6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7