If you've defined it as def method_missing ...
, you have created an instance method, but your code indicates you are sending the dynamic message to the class itself. You need to define self.method_missing
on NewsletterMailer
if you want it to execute as you've written it.
That being said, I would recommend against this design for your particular case. The idea I would keep in mind is that you have behavior - the methods and actions that all newsletters have in common - and data, which describes the particulars of any given list and/or its newsletter. In most cases, these should remain separate and distinct, with your code describing behavior, and a database holding your data. It makes little sense to define a new method for each mailing list, when you could just have a method send_newsletter
that takes the list as an argument.