|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Need help with Ruby code in doc example about setting env variableHello,
I am adding a blurb in 6.5 docs about setting the environment for running on GlassFish. The Rails Environment setting in the Project Properties dialog box does not affect running the app on GlassFish (on for WEBrick and Mongrel). Instead you need to set the environment in your environment.rb file. In my testing, I have done this RAILS_ENV = 'test' I notice that the comments in the file say to do this: ENV['RAILS_ENV'] ||= 'test' Should that be how I document it? I don't understand the ||= part. I know that || means or. I am guessing that ||= means: If ENV['RAILS_ENV'] has a value use that, otherwise set it to 'test' ???? I also notice this code: RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION So, why isn't that ENV['RAILS_GEM_VERSION'] ||= '2.1.1' I feel that I am not understanding the usage of ENV[] and environment variables. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Need help with Ruby code in doc example about setting env variableHello Chris,
I do not have all the answers but will try to address as many as I can. Here we go: You wrote: "I notice that the comments in the file say to do this: ENV['RAILS_ENV'] ||= 'test' Should that be how I document it? I don't understand the ||= part. I know that || means or. I am guessing that ||= means: If ENV['RAILS_ENV'] has a value use that, otherwise set it to 'test' ????" -- Quite correct. This is how ruby shortens code. You wrote: "I also notice this code: RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION So, why isn't that ENV['RAILS_GEM_VERSION'] ||= '2.1.1'" -- The reason for doing that is RAILS_GEM_VERSION constant can be defined elsewhere. In particular, if you "freeze" a specific version of Rails in the vendors directory then that particular version overrides the currently installed Rails version using "gem intall command" in your current environment. Freezing a specific version of Rails in the vendor directory is a common practice (or shall we say a best practice?) to ensure that your application runs against the same version of Rails in ANY environment that you deploy. You wrote: "I feel that I am not understanding the usage of ENV[] and environment variables." If you go through Obie Fernandez's excellent "The Rails Way" text, he explains all this in detail in the very first chapter of his book. As you move beyond the introductory materials in Rails, Obie's book becomes very useful. Hope this helps. Regards, Bharat |
|
|
Re: Need help with Ruby code in doc example about setting env variableIn other words,
I should use the following code example to show how to set RAILS_ENV in the environment.rb file ENV['RAILS_ENV'] ||= 'test' Thanks for the pointer to the book. I was able to look at Chapter 1 and it does provide some helpful information. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Need help with Ruby code in doc example about setting env variableWhich book?
Il giorno 17/ott/08, alle ore 22:21, Chris Kutler ha scritto: > In other words, > > I should use the following code example to show how to set RAILS_ENV > in the environment.rb file > > ENV['RAILS_ENV'] ||= 'test' > > Thanks for the pointer to the book. I was able to look at Chapter 1 > and it does provide some helpful information. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Need help with Ruby code in doc example about setting env variableEarlier in the thread, Bharat wrote
> If you go through Obie Fernandez's excellent "The Rails Way" text, he > explains all this in detail in the very first chapter of his book. As you > move beyond the introductory materials in Rails, Obie's book becomes very > useful. (((Bonsai Studio))) - Giuseppe wrote: > Which book? > > Il giorno 17/ott/08, alle ore 22:21, Chris Kutler ha scritto: > >> In other words, >> >> I should use the following code example to show how to set RAILS_ENV >> in the environment.rb file >> >> ENV['RAILS_ENV'] ||= 'test' >> >> Thanks for the pointer to the book. I was able to look at Chapter 1 >> and it does provide some helpful information. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... >> For additional commands, e-mail: users-help@... >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Need help with Ruby code in doc example about setting env variableThanks Chris, didn't get it.
Il giorno 17/ott/08, alle ore 22:56, Chris Kutler ha scritto: > Earlier in the thread, Bharat wrote > >> If you go through Obie Fernandez's excellent "The Rails Way" text, he >> explains all this in detail in the very first chapter of his book. >> As you >> move beyond the introductory materials in Rails, Obie's book >> becomes very >> useful. > > > (((Bonsai Studio))) - Giuseppe wrote: >> Which book? >> >> Il giorno 17/ott/08, alle ore 22:21, Chris Kutler ha scritto: >> >>> In other words, >>> >>> I should use the following code example to show how to set >>> RAILS_ENV in the environment.rb file >>> >>> ENV['RAILS_ENV'] ||= 'test' >>> >>> Thanks for the pointer to the book. I was able to look at Chapter >>> 1 and it does provide some helpful information. >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscribe@... >>> For additional commands, e-mail: users-help@... >>> >>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@... >> For additional commands, e-mail: users-help@... >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@... > For additional commands, e-mail: users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free embeddable forum powered by Nabble | Forum Help |