# Webrick: does it honour ENV\['RAILS\_ENV'\] ||= 'production'

**URL:** <https://www.ruby-forum.com/t/webrick-does-it-honour-env-rails-env-production/120214>\
**Category:** Rails\
**Created:** [November 14, 2007, 8:28pm UTC](https://www.ruby-forum.com/t/webrick-does-it-honour-env-rails-env-production/120214 "2007-11-14T20:28:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cujigar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/2acd7d/32.png) [@cujigar](https://www.ruby-forum.com/u/cujigar)\
**Post date:** [November 14, 2007, 8:28pm UTC](https://www.ruby-forum.com/t/webrick-does-it-honour-env-rails-env-production/120214/1 "2007-11-14T20:28:34Z")

</div>

my environment.rb contains  
ENV[‘RAILS\_ENV’] ||= ‘production’

when i start webrick with command  
ruby script\server

it still runs in development mode. Is this expected behavior of  
webrick?? why?

the only way to run webrick in peoduction mode,it seems, is by :-  
ruby script\server -e production

---

<div class="post-metadata">

**Author:** ![cujigar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/2acd7d/32.png) [@cujigar](https://www.ruby-forum.com/u/cujigar)\
**Post date:** [November 14, 2007, 8:49pm UTC](https://www.ruby-forum.com/t/webrick-does-it-honour-env-rails-env-production/120214/2 "2007-11-14T20:49:28Z")

</div>

The ||= operator indicates that if RAILS\_ENV isn’t already set, then  
Ruby should set it (in this case, to ‘production’). I’m willing to  
bet that WEBrick sets it to development before it gets to that line  
environment.rb. Try changing ||= to = (I don’t know if that will  
work).

–Jeremy

On 11/14/07, Jigar G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## the only way to run webrick in peoduction mode,it seems, is by :- ruby script\server -e production
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
[http://www.jeremymcanally.com/](http://www.jeremymcanally.com/)

My books:  
Ruby in Practice

> **[Ruby in Practice](https://www.manning.com/books/ruby-in-practice)**
>
> Like Ruby itself, Ruby in Practice will make you more productive. The book shows you practical techniques and strategies for small projects and large-scale environments. A cookbook-style reference, it gives you concrete examples of systems...

My free Ruby e-book

> **[Site not found · DreamHost](http://www.humblelittlerubybook.com/)**
>
> The owner of this domain has not yet uploaded their website.

My blogs:

> **[Site not found · DreamHost](http://www.mrneighborly.com/)**
>
> The owner of this domain has not yet uploaded their website.

[http://www.rubyinpractice.com/](http://www.rubyinpractice.com/)

---

<div class="post-metadata">

**Author:** ![cujigar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/2acd7d/32.png) [@cujigar](https://www.ruby-forum.com/u/cujigar)\
**Post date:** [November 14, 2007, 9:03pm UTC](https://www.ruby-forum.com/t/webrick-does-it-honour-env-rails-env-production/120214/3 "2007-11-14T21:03:52Z")

</div>

thanks for reply, it was thoughtful

But alas,

ENV[‘RAILS\_ENV’] = ‘production’

doesn’t work either.

I think I’ll stick to -e production

Jeremy McAnally wrote:

> The ||= operator indicates that if RAILS\_ENV isn’t already set, then  
> Ruby should set it (in this case, to ‘production’). I’m willing to  
> bet that WEBrick sets it to development before it gets to that line  
> environment.rb. Try changing ||= to = (I don’t know if that will  
> work).
> 
> –Jeremy
> 
> On 11/14/07, Jigar G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > ## the only way to run webrick in peoduction mode,it seems, is by :- ruby script\server -e production
> > 
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > 
> > >
> 
> –  
> [http://www.jeremymcanally.com/](http://www.jeremymcanally.com/)
> 
> My books:  
> Ruby in Practice  
> [Ruby in Practice](http://www.manning.com/mcanally/)
> 
> My free Ruby e-book  
> [http://www.humblelittlerubybook.com/](http://www.humblelittlerubybook.com/)
> 
> My blogs:  
> [http://www.mrneighborly.com/](http://www.mrneighborly.com/)  
> [http://www.rubyinpractice.com/](http://www.rubyinpractice.com/)
