Skip to content

Instantly share code, notes, and snippets.

@ladyrassilon
Created August 20, 2012 13:16
Show Gist options
  • Save ladyrassilon/3403900 to your computer and use it in GitHub Desktop.
Save ladyrassilon/3403900 to your computer and use it in GitHub Desktop.
method missing on notifier
class Notifier < ActionMailer::Base
def method_missing(method_name, *args, &block)
puts method_name
body = "Method name - #{method_name} \n"
mail(:to => Notifier.emergency, :subject => "Notifier is missing a called method", :body => body)
#I've tried putting in super and not super here
end
def respond_to?(method_name, include_private = false)
true
end
end
@iNecas
Copy link

iNecas commented Aug 20, 2012

Try

def self.method_missing
# ...
end

and

def self.respond_to?
# ...
end
instead. Otherwise it's applied on the instances of class Notifier, not the class itself

@iNecas
Copy link

iNecas commented Aug 20, 2012

My previous suggestion wouldn't probably work out of box.

The solution could be leaving your current code and defining:

def self.respond_to?(method)
  return true if method == :make_pizza
  super
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment