LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > Ruby/Rails > ENV['myval'] is not processed under lsapi

Reply
 
Thread Tools Display Modes
  #1  
Old 09-05-2006, 09:33 PM
dlhhyct dlhhyct is offline
Member
 
Join Date: Aug 2006
Posts: 41
Default ENV['myval'] is not processed under lsapi

in my <rail_root>/config/environment.rb, I set several global variables used throughout app. for example:
Code:
ENV['image_dir'] = '/folder1'
ENV['record_click_trail'] = 'yes'
when i try use those var in a controller or display the value in a rhtml page, eg, <%= ENV['image_dir'] %>
* If rail app started under webrick or mongrel, they works fine.
* under ruby lsapi, all of those var seems not processed and are nil when I try to use them.
Reply With Quote
  #2  
Old 09-06-2006, 12:42 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,583
Fixed in ruby LSAPI 1.7, please upgrade.
http://www.litespeedtech.com/products/webserver/lsapi/
the gem file will be available soon.
Reply With Quote
  #3  
Old 09-06-2006, 12:45 PM
dlhhyct dlhhyct is offline
Member
 
Join Date: Aug 2006
Posts: 41
Default u so fast

thank you.
Reply With Quote
  #4  
Old 09-06-2006, 01:06 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,583
You are welcome.
Please let me know it is fixed or not. you may need to uninstall the gem first with "gem uninstall ruby-lsapi".
Reply With Quote
  #5  
Old 09-06-2006, 02:17 PM
dlhhyct dlhhyct is offline
Member
 
Join Date: Aug 2006
Posts: 41
Default almost

ENV[] values in environment.rb are recognized now. but config/environments/production.rb (test.rb, development.rb) can overwrite the same variable, which is not doing that under lsapi 1.7
Reply With Quote
  #6  
Old 09-06-2006, 02:33 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,583
Are you sure? I believe values in environment.rb will override the value set in config/environments/producion.rb, etc. The same behavior under mongrel.
Reply With Quote
  #7  
Old 09-06-2006, 03:26 PM
dlhhyct dlhhyct is offline
Member
 
Join Date: Aug 2006
Posts: 41
Default environment

* environment.rb stores all variables used for the webapp.
* environments/*.rb can choose to customize certain variables depends on environment.
for example, in my environment.rb, i set ENV['image_dir']='/uploaded_images', which is same for all environments, but in my environment/test.rb, I can customize ENV['image_dir']='/tmp' since i don't need to keep image when running test cases.

following is copy paste from agile RoR book, pg 238:
----------------------------------------------------------
Environment files typically do three things
* They set up the Ruby load path. This is how your application can find things such as models and views when it’s running.
* They create resources used by your application (such as the logger).
* They set various configuration options, both for Rails and for your application.

The first two of these are normally application-wide and so are done in environment.rb. The configuration options often vary depending on the environment and so are likely to be set in the environment-specific files in the environments directory.
Reply With Quote
  #8  
Old 09-06-2006, 07:06 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,583
I think it is a ruby bug or just the way it works. I cannot override a ENV[] variable in production.rb or development.rb if the same variable is set in environment.rb. Tried mongrel, same result.
I tried ruby 1.8.4, 1.8.5 and rails 1.1.6.
What's yours?
Reply With Quote
  #9  
Old 09-06-2006, 07:42 PM
dlhhyct dlhhyct is offline
Member
 
Join Date: Aug 2006
Posts: 41
Default thank you

you are right. only if i comment out same var in the environment.rb, then var in each env are read. i guess no overriding then, but that was the impression i got from the doc. I guess I should just leave the main environment.rb alone. Thank you.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setup for Rails via Litespeed Ruby LSAPI Justin Ruby/Rails 2 12-08-2007 07:19 PM
Ruby LSAPI 2.4 and PHP LSAPI 3.1 released mistwang News 0 04-24-2007 03:35 PM
Rails, LSAPI, Rewrites, Contexts, Authentication mabonyi Install/Configuration 2 02-11-2007 06:10 PM
LSAPI Ruby v1.12, PHP v2.4 Released mistwang News 0 01-10-2007 01:18 PM
LSWS Ruby LSAPI zoom Install/Configuration 2 05-14-2006 04:50 PM


All times are GMT -7. The time now is 11:05 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.