# How to extend ActionMailer

**URL:** <https://www.ruby-forum.com/t/how-to-extend-actionmailer/167338>\
**Category:** Rails\
**Created:** [May 6, 2009, 9:04pm UTC](https://www.ruby-forum.com/t/how-to-extend-actionmailer/167338 "2009-05-06T21:04:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [May 6, 2009, 9:04pm UTC](https://www.ruby-forum.com/t/how-to-extend-actionmailer/167338/1 "2009-05-06T21:04:18Z")

</div>

I wish to extend ActionMailer::Base by method chaining a class instance  
variable:

module ActionMailer  
class Base  
class \<\< self  
def method\_name  
…

What is the magic incantation to accomplish this?

I cannot get this to work with action mailer:

module MyMethods

def self.include(base)  
base.alias\_method\_chain :method\_name, :my\_method

def method\_name\_with\_my\_method  
… stuff  
method\_name\_without\_my\_method  
end  
…  
end

class ActionMailer::Base  
include MyMethods  
end

require ‘my\_methods’

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [May 6, 2009, 9:19pm UTC](https://www.ruby-forum.com/t/how-to-extend-actionmailer/167338/2 "2009-05-06T21:19:47Z")

</div>

James B. wrote:

> I wish to extend ActionMailer::Base by method chaining a class instance  
> variable:

I was ever so close:

class ActionMailer::Base

class \<\< self

```
def self.include(base)

   base.alias_method_chain :method_name, :my_method

   def method_name_with_my_method
     ...
     method_name_without_my_method
   end
end

```

end  
end
