Class: RuboCop::Cop::Captive::Rails::NoEmailFromController

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/captive/rails/no_email_from_controller.rb

Overview

This cop checks for email delivery methods in controllers. Sending email in controllers is not allowed in order to follow the MVC standard An email must be sent from a Model

Constant Summary collapse

MSG =
"Do not send emails from controllers. Because it doesn't follow the MVC standard"

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rubocop/cop/captive/rails/no_email_from_controller.rb', line 17

def on_send(node)
  return unless email_delivery?(node)

  controller_class = find_controller_class(node)
  return unless controller_class

  add_offense(node, message: MSG)
end