# Stopping error mailer on development

**URL:** <https://www.ruby-forum.com/t/stopping-error-mailer-on-development/96993>\
**Category:** Rails\
**Created:** [July 4, 2006, 12:51am UTC](https://www.ruby-forum.com/t/stopping-error-mailer-on-development/96993 "2006-07-04T00:51:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [July 4, 2006, 12:51am UTC](https://www.ruby-forum.com/t/stopping-error-mailer-on-development/96993/1 "2006-07-04T00:51:51Z")

</div>

I sleep better with it in place in production mode and I only get one  
error notice - every once in a while for a problem that I have fixed in  
development branch that I am not ready to merge in the main trunk yet. I  
want to keep the error mailer code in place in development code for  
obvious reasons and even though I can set up filters for my mail system,  
how can I simply shut it off for development mode?

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [July 4, 2006, 1:35am UTC](https://www.ruby-forum.com/t/stopping-error-mailer-on-development/96993/2 "2006-07-04T01:35:19Z")

</div>

I’ve been getting errors when I Marshal ActiveRecord objects in my app.

The following will throw a TypeError every time:

session[:user] = Person.create(hash)

However, the following will not throw a TypeError:

person = Person.find(1)  
session[:user] = person

This will not throw a TypeError either:

person = Person.create(hash)  
person.reload  
session[:user] = person

If I had to guess, I would guess that Person.create() returns an  
ActiveRecord object that possibly references a database connection, or  
some other attribute that can’t be Marshalled. Person.find() returns an  
ActiveRecord object where all attributes can be Marshalled. Does anyone  
have more in depth information on why one can be Marshaled and not the  
other? Anyway, the rails docs make no reference regarding a possible  
difference with the state of the object returned by create() vs find().

Regards,  
Steven

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [July 4, 2006, 1:44am UTC](https://www.ruby-forum.com/t/stopping-error-mailer-on-development/96993/3 "2006-07-04T01:44:41Z")

</div>

On Mon, 2006-07-03 at 16:32 -0600, Steven H. wrote:

> session[:user] = person  
> some other attribute that can’t be Marshalled. Person.find() returns an  
> ActiveRecord object where all attributes can be Marshalled. Does anyone  
> have more in depth information on why one can be Marshaled and not the  
> other? Anyway, the rails docs make no reference regarding a possible  
> difference with the state of the object returned by create() vs find().

* * *

my first thought is that rather than creating a new email to the  
[rubyonrails.org](http://rubyonrails.org) mail list, you clicked reply to my message which just  
intruded onto my thread.

my second thought is that the reason session[:user] =  
Person.create(hash) throws an error is that Person.create is a method,  
not an object. If you assign a variable (hash or otherwise) then you can  
possibly set a session[:hash\_key] =\> variable (not session[:has\_key] =\>  
method

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [July 4, 2006, 2:03am UTC](https://www.ruby-forum.com/t/stopping-error-mailer-on-development/96993/4 "2006-07-04T02:03:24Z")

</div>

Hi Craig,

My apologies. I didn’t mean to interrupt your thread. I thought  
threads were managed by the Subject and that if I simply altered the  
subject then your thread would not be touched.

BTW, Person.create() returns a reference to an object.

-Steven

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [July 4, 2006, 2:06am UTC](https://www.ruby-forum.com/t/stopping-error-mailer-on-development/96993/5 "2006-07-04T02:06:34Z")

</div>

On Mon, 2006-07-03 at 16:59 -0600, Steven H. wrote:

> Hi Craig,
> 
> My apologies. I didn’t mean to interrupt your thread. I thought  
> threads were managed by the Subject and that if I simply altered the  
> subject then your thread would not be touched.

* * *

## threads are maintained by an id # in the header

> BTW, Person.create() returns a reference to an object.

* * *

that is why you can set person = Person.create()

but Person.create() is a method that returns an object

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [July 5, 2006, 3:17pm UTC](https://www.ruby-forum.com/t/stopping-error-mailer-on-development/96993/6 "2006-07-05T15:17:11Z")

</div>

On Mon, 2006-07-03 at 15:49 -0700, Craig W. wrote:

> I sleep better with it in place in production mode and I only get one  
> error notice - every once in a while for a problem that I have fixed in  
> development branch that I am not ready to merge in the main trunk yet. I  
> want to keep the error mailer code in place in development code for  
> obvious reasons and even though I can set up filters for my mail system,  
> how can I simply shut it off for development mode?

* * *

is there something I can put at the top of error\_mailer.rb model file  
that would have this only work in RAILS\_ENV=production ?

Craig
