# Difficulty with body in ActionMailer

**URL:** <https://www.ruby-forum.com/t/difficulty-with-body-in-actionmailer/91529>\
**Category:** Rails\
**Created:** [April 10, 2007, 3:34am UTC](https://www.ruby-forum.com/t/difficulty-with-body-in-actionmailer/91529 "2007-04-10T03:34:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [April 10, 2007, 3:34am UTC](https://www.ruby-forum.com/t/difficulty-with-body-in-actionmailer/91529/1 "2007-04-10T03:34:19Z")

</div>

AWRDwRv2 is pretty vague on the @body part of setting up a mailer. Here  
is my problem:

> > p = Person.find(1)  
> > =\> #Person:0x45c944c

> > SiteMailer.request\_admin\_approval§  
> > NoMethodError: You have a nil object when you didn’t expect it!  
> > You might have expected an instance of Array.  
> > The error occurred while evaluating nil.[]=  
> > from site\_mailer.rb:10:in `request\_admin\_approval’  
> > from (irb):2

ln def self.request\_admin\_approval(person)  
@subject = ‘New User Notification’  
10 @body[“person”] = person  
@recipients = person.email  
@from = ‘removed\_email\_address@domain.invalid’  
@sent\_on = Time.now  
@headers = {}  
15 end

---

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [April 10, 2007, 3:50pm UTC](https://www.ruby-forum.com/t/difficulty-with-body-in-actionmailer/91529/2 "2007-04-10T15:50:13Z")

</div>

Taylor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) said:

> The error occurred while evaluating nil.[]=  
> from site\_mailer.rb:10:in `request\_admin\_approval’  
> from (irb):2
> 
> ln def self.request\_admin\_approval(person)  
> @subject = ‘New User Notification’  
> 10 @body[“person”] = person

body = :person =\> person

That should do what you are looking for.

–  
Mark Loeser  
email - mark AT halcy0n DOT com  
web - [http://www.halcy0n.com](http://www.halcy0n.com)

---

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [April 10, 2007, 4:28pm UTC](https://www.ruby-forum.com/t/difficulty-with-body-in-actionmailer/91529/3 "2007-04-10T16:28:50Z")

</div>

> body = :person =\> person
> 
> That should do what you are looking for.

Thanks, Mark. Where did that come from? There isn’t anything like it  
in AWDwRv2.

---

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [April 10, 2007, 4:32pm UTC](https://www.ruby-forum.com/t/difficulty-with-body-in-actionmailer/91529/4 "2007-04-10T16:32:19Z")

</div>

Taylor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) said:

> > body = :person =\> person
> > 
> > That should do what you are looking for.
> 
> Thanks, Mark. Where did that come from? There isn’t anything like it  
> in AWDwRv2.

[http://api.rubyonrails.org](http://api.rubyonrails.org) has some nice examples on it. It currently  
seems to be down though.

–  
Mark Loeser  
email - mark AT halcy0n DOT com  
web - [http://www.halcy0n.com](http://www.halcy0n.com)

---

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [April 10, 2007, 5:12pm UTC](https://www.ruby-forum.com/t/difficulty-with-body-in-actionmailer/91529/5 "2007-04-10T17:12:33Z")

</div>

This syntax doesn’t work for me:

> body = :person =\> person

But this does:

body :person =\> person

The API docs conflict with AWDwRv2 and the mailer generator in the  
format. The API doesn’t use ‘=’ but the generator and AWD do. I assume  
the API docs are out of date, but then @body = does NOT work. Bummer.

---

<div class="post-metadata">

**Author:** ![taylorstrait](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b5a626/32.png) [@taylorstrait](https://www.ruby-forum.com/u/taylorstrait)\
**Post date:** [April 10, 2007, 6:16pm UTC](https://www.ruby-forum.com/t/difficulty-with-body-in-actionmailer/91529/6 "2007-04-10T18:16:36Z")

</div>

Taylor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) said:

> This syntax doesn’t work for me:
> 
> > body = :person =\> person
> 
> But this does:
> 
> body :person =\> person

Yup, oops. I meant to remove that =. I always go by whatever is on  
[api.rubyonrails.org](http://api.rubyonrails.org).

–  
Mark Loeser  
email - mark AT halcy0n DOT com  
web - [http://www.halcy0n.com](http://www.halcy0n.com)
