diff --git a/app/helpers/react_on_rails_helper.rb b/app/helpers/react_on_rails_helper.rb index fd169058e..3465fa9d9 100644 --- a/app/helpers/react_on_rails_helper.rb +++ b/app/helpers/react_on_rails_helper.rb @@ -345,7 +345,7 @@ def initialize_redux_stores def rails_context(server_side:) @rails_context ||= begin result = { - inMailer: controller.present? && controller.is_a?(ActionMailer::Base), + inMailer: in_mailer?, # Locale settings i18nLocale: I18n.locale, i18nDefaultLocale: I18n.default_locale @@ -400,4 +400,11 @@ def send_tag_method(tag_method_name, args) options = args.delete_if { |key, _value| %i(hot static).include?(key) } send(tag_method_name, *assets, options) unless assets.empty? end + + def in_mailer? + return false unless controller.present? + return false unless defined?(ActionMailer::Base) + + controller.is_a?(ActionMailer::Base) + end end