# Display message when not running off the production database

**URL:** <https://www.ruby-forum.com/t/display-message-when-not-running-off-the-production-database/97217>\
**Category:** Rails\
**Created:** [July 5, 2006, 6:21pm UTC](https://www.ruby-forum.com/t/display-message-when-not-running-off-the-production-database/97217 "2006-07-05T18:21:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@ben](https://www.ruby-forum.com/u/ben)\
**Post date:** [July 5, 2006, 6:21pm UTC](https://www.ruby-forum.com/t/display-message-when-not-running-off-the-production-database/97217/1 "2006-07-05T18:21:40Z")

</div>

Hi,

Is there a way to output a message to the top of every page when the  
rails application is not running from the production database?

Thanks

---

<div class="post-metadata">

**Author:** ![ben](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@ben](https://www.ruby-forum.com/u/ben)\
**Post date:** [July 5, 2006, 7:02pm UTC](https://www.ruby-forum.com/t/display-message-when-not-running-off-the-production-database/97217/2 "2006-07-05T19:02:20Z")

</div>

On 7/5/06, ben [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a way to output a message to the top of every page when the  
> rails application is not running from the production database?

Do you mean as an error message if the database crashes or as a way to  
say “Hey, this is a staging box.”?

If it’s the former, I’m not sure since it would depend on how usable  
your app really is if the database blows up.

If it’s the latter, you can get the current environment name from the  
constant RAILS\_ENV and compare it to whatever name you’re looking for  
– probably “production”.

– James

---

<div class="post-metadata">

**Author:** ![ben](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@ben](https://www.ruby-forum.com/u/ben)\
**Post date:** [July 5, 2006, 7:08pm UTC](https://www.ruby-forum.com/t/display-message-when-not-running-off-the-production-database/97217/3 "2006-07-05T19:08:30Z")

</div>

On 5-Jul-06, at 12:21 PM, ben wrote:

> Is there a way to output a message to the top of every page when the  
> rails application is not running from the production database?

Use the RAILS\_ENV environment variable to determine what environment  
you’re running in. In app/views/layouts/application.rhtml, something  
like:

\<%= ‘Not in production’ unless ENV[‘RAILS\_ENV’] == ‘production’ %\>

/Jeff

---

<div class="post-metadata">

**Author:** ![ben](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@ben](https://www.ruby-forum.com/u/ben)\
**Post date:** [July 6, 2006, 10:19am UTC](https://www.ruby-forum.com/t/display-message-when-not-running-off-the-production-database/97217/4 "2006-07-06T10:19:56Z")

</div>

Jeffrey H. wrote:

> On 5-Jul-06, at 12:21 PM, ben wrote:
> 
> > Is there a way to output a message to the top of every page when the  
> > rails application is not running from the production database?
> 
> Use the RAILS\_ENV environment variable to determine what environment  
> you’re running in. In app/views/layouts/application.rhtml, something  
> like:
> 
> \<%= ‘Not in production’ unless ENV[‘RAILS\_ENV’] == ‘production’ %\>
> 
> /Jeff

thanks, does a perfect job
