ankane / ahoy_email

First-party email analytics for Rails
MIT License
1.11k stars 137 forks source link

TypeError - no implicit conversion of nil into String #133

Closed greena13 closed 5 years ago

greena13 commented 5 years ago

When I enable ahoy_email and try and send an email that previously worked fine, I get the error:

TypeError - no implicit conversion of nil into String
greena13 commented 5 years ago

The default detection of secret_key_base did not work in my case:

AhoyEmail.secret_token ||= begin
        creds =
          if app.respond_to?(:credentials) && app.credentials.secret_key_base
            app.credentials
          elsif app.respond_to?(:secrets)
            app.secrets
          else
            app.config
          end

        creds.respond_to?(:secret_key_base) ? creds.secret_key_base : creds.secret_token
      end

So I had to manually override it in the ahoy_email initializer:

AhoyEmail.secret_token = Rails.application.secret_key_base

Perhaps the secret_token configuration option could be documented in the Readme?