How to switch to "Production" mode?

Hi guys,

This is probably very easy question to answer but is perplexing a
newbie ROR guy like me...

I have successfully set up a Netbeans, MySQL server and gotten my
first RailsApplication1 set up. On my http://localhost:3000 page, I
can see that all is set up and well. Clicking on "About your
application's environment" shows me a nice ajax view that says:

Ruby version 1.8.6 (i386-mswin32)
RubyGems version 0.9.4
Rails version 2.0.2
Active Record version 2.0.2
Action Pack version 2.0.2
Active Resource version 2.0.2
Action Mailer version 2.0.2
Active Support version 2.0.2
Application root C:/work/Prj_ROR/RailsApplication1
Environment development
Database adapter mysql

My question is - and I have been scratching my head over the past half
hour fiddling with various files including the environment.rb file -
and I still have no clue HOW to run my local Ruby On Rails App in
PRODUCTION mode instead of DEVELOPMENT mode as it is right now...

Surely, there must be a simple way to do this?

Anyone?

Sorry for this really dumb question.

Ellils

Hi!

Thanks. This seems to work. I am getting a different "environment"
message now. Instead of saying the whole chunk as mentioned above, it
now says:
"
Routing Error
No route matches "/rails/info/properties" with {:method=>:get}
"

which probably means I have to configure my Route I suppose? Not sure
if this is the correct interpretation of what is happening here...

Another question would be more pertaining to Netbeans. Thibaut's
method seems to be applicable only if I run ruby script/server -e
production in command line. I was wondering how to force the
application to be working in production mode while inside Netbeans
IDE. I was hoping to do everything within Netbeans IDE and not to
have to worry about command line at all.

Regards,
Ellils

I’m going to really simplify this for you:

Don’t. There’s no good reason I can think of to run Rails in production mode via Netbeans. Of course, you may have one, but let’s see if we can get around it.

Production mode is for production. Models and controllers are cached, and other things work differently but none of those should change how your application behaves code-wise. If you’re trying to get things like page caching and other things to work in development mode, simply see the environments/ folder in the config folder. You can change how each environment works. If you’ve got code that checks for different environment modes and does different things, you should have tests to check that functionality.

Let us know if you still need help :slight_smile:

Hi Brian,

Okay, sounds simple enough :slight_smile:

So whenever I want to view my production mode site, I just have to
jump over to DOS and run webrick in production mode.

Regards,
Ellils

No, you should be able to view your “production site” in development mode. This way you don’t have to keep restarting your server when you change controllers and models.

If you still want to use production mode from within NetBeans, this is
described in the following post:
http://www.nabble.com/Re%3A-Changing-Mongrel-parameters--p14659714.html

-- Tor

uncomment in your environment.rb

# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'