Last active
March 24, 2016 09:10
-
-
Save LolWalid/06422f5525908e6b6567 to your computer and use it in GitHub Desktop.
Why can I call method as class one but I have to define it as instance method in mailer?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mailer.send_mail('subject', 'message') | |
class Mailer < ActionMailer::Base | |
def send_mail(subject, message) | |
subject = subject | |
@message = message | |
mail(to: '[email protected]', subject: subject) | |
end | |
end | |
# https://github.com/rails/rails/blob/master/actionmailer/lib/action_mailer/base.rb | |
module ActionMailer | |
class Base < AbstractController::Base | |
class << self | |
protected | |
def method_missing(method_name, *args) # :nodoc: | |
if action_methods.include?(method_name.to_s) | |
MessageDelivery.new(self, method_name, *args) | |
else | |
super | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment