|
|

09-05-2006, 09:33 PM
|
|
Member
|
|
Join Date: Aug 2006
Posts: 41
|
|
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.
|

09-06-2006, 12:45 PM
|
|
Member
|
|
Join Date: Aug 2006
Posts: 41
|
|
u so fast
thank you.
|

09-06-2006, 01:06 PM
|
|
LiteSpeed Staff
|
|
Join Date: May 2003
Location: New Jersey
Posts: 7,603
|
|
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".
|

09-06-2006, 02:17 PM
|
|
Member
|
|
Join Date: Aug 2006
Posts: 41
|
|
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
|

09-06-2006, 02:33 PM
|
|
LiteSpeed Staff
|
|
Join Date: May 2003
Location: New Jersey
Posts: 7,603
|
|
|
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.
|

09-06-2006, 03:26 PM
|
|
Member
|
|
Join Date: Aug 2006
Posts: 41
|
|
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.
|

09-06-2006, 07:06 PM
|
|
LiteSpeed Staff
|
|
Join Date: May 2003
Location: New Jersey
Posts: 7,603
|
|
|
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?
|

09-06-2006, 07:42 PM
|
|
Member
|
|
Join Date: Aug 2006
Posts: 41
|
|
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.
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:33 PM.
|
|