ENV['RAILS_ENV'] returns nil when called inside Rails 2.3.4 initializer

Discussion in 'Ruby/Rails' started by thbar, Jan 29, 2010.

  1. thbar

    thbar Active Member


    if I use an initializer under config/initializer/myfile.rb, it seems that when the code is called, ENV['RAILS_ENV'] is empty when I use LiteSpeed, whereas it has a value of development or production if I use ruby script/server.

    Is it a known issue ?

    My work-around has been to hard-code to production for the moment.


    -- Thibaut
  2. mistwang

    mistwang LiteSpeed Staff

    If you use dispatch.lsapi setup, you need to set "RAILS_ENV" in "Environment" configuration for the external app.
  3. thbar

    thbar Active Member

    I've been reading a lot but I'm not sure what's the right way to do things.

    I have a virtual host, but it doesn't have anything in the "external app" tab. Should I add a lsapi external app ?

    I'm a bit confused about dispatch.lsapi vs RailsRunner etc - what is the recommended way to run a Rails 2.3.4 app ?


    -- Thibaut
  4. mistwang

    mistwang LiteSpeed Staff

    It is recommended to patch rack code and use the RailsRunner setup, only need configuration of a rails context.
  5. thbar

    thbar Active Member

    Thank you - I will try that.
  6. Grzegorz Derebecki

    Grzegorz Derebecki Well-Known Member

  7. thbar

    thbar Active Member

    Hey Grzegorz,

    thanks for the links - I will give these a go next time I deploy to this site (coming weeks).


    -- Thibaut
  8. backlashforblow

    backlashforblow New Member

    I used to work with rails 2.3.2 before and then
    I decided to upgrade to version 2.3.4. " ERRORS ARE STILL THERE "
    I don't know why this is happening. Everything worked
    fine in 2.3.2 and now it doesn't. :confused::confused:

Share This Page