Created
August 20, 2012 13:16
-
-
Save ladyrassilon/3403900 to your computer and use it in GitHub Desktop.
method missing on notifier
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
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 |
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
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
Both of these errors happen, although ideally i'd like .deliver to work
'1.9.3p194 :001 > Notifier.make_pizza("testing").deliver
NoMethodError: undefined method
make_pizza' for Notifier:Class from /Users/rassilon/.rvm/gems/ruby-1.9.3-p194/gems/actionmailer-3.0.3/lib/action_mailer/deprecated_api.rb:74:in
method_missing'from /Users/rassilon/.rvm/gems/ruby-1.9.3-p194/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:427:in
method_missing' from (irb):1 from /Users/rassilon/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in
start'from /Users/rassilon/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in
start' from /Users/rassilon/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.3/lib/rails/commands.rb:23:in
<top (required)>'from script/rails:6:in
require' from script/rails:6:in
1.9.3p194 :002 > Notifier.make_pizza
NoMethodError: undefined method
make_pizza' for Notifier:Class from /Users/rassilon/.rvm/gems/ruby-1.9.3-p194/gems/actionmailer-3.0.3/lib/action_mailer/deprecated_api.rb:74:in
method_missing'from /Users/rassilon/.rvm/gems/ruby-1.9.3-p194/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:427:in
method_missing' from (irb):2 from /Users/rassilon/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in
start'from /Users/rassilon/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in
start' from /Users/rassilon/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.3/lib/rails/commands.rb:23:in
<top (required)>'from script/rails:6:in
require' from script/rails:6:in
'