How can I go about accessing constants in my templates? Both from the current controller, as well as external classes? Primarily I''m concerned with using constants from a class that defines all string messages available in the application. Where should the class containing these constants be placed in the rails directory structure, and how can it be accessed in the controller templates? Thanks, Steve
> How can I go about accessing constants in my templates? Both from the > current controller, as well as external classes? Primarily I''m concerned > with using constants from a class that defines all string > messages available > in the application. Where should the class containing these constants be > placed in the rails directory structure, and how can it be accessed in the > controller templates?Err...nevermind. I had placed the Messages class in lib/, however, it appears that changes made in lib/ are not automatically reloaded when saved. I had to restart the WEBrick server, and then everything worked as expected. I had assumed that since changes in app/ were automatically reloaded that that would be the case throughout. Is this behavior standard across all web servers with rails, or is it just specific to WEBrick? Steve
On Tuesday 05 April 2005 17:27, Steve V wrote:> I had assumed that since changes in app/ were automatically > reloaded that that would be the case throughout.Any and all files that you load using require_dependency ''filename'' will be reloaded. If you use require, they will not. I''m guessing you were using require.> Is this behavior standard > across all web servers with rails, or is it just specific to WEBrick?No, this is a Rails feature. So long as the Rails environment is development, require_dependency files will be reloaded. -- Nicholas Seckar aka. Ulysses
> On Tuesday 05 April 2005 17:27, Steve V wrote: > > I had assumed that since changes in app/ were automatically > > reloaded that that would be the case throughout. > Any and all files that you load using require_dependency > ''filename'' will be > reloaded. If you use require, they will not. I''m guessing you were using > require. > > > Is this behavior standard > > across all web servers with rails, or is it just specific to WEBrick? > No, this is a Rails feature. So long as the Rails environment is > development, > require_dependency files will be reloaded.Actually I wasn''t using anything. I was just referencing Messages::SOME_MESSAGE. Including require_dependency in the controller did do exactly what you said though. You said that this will happen when in development. What is the behavior in production? Will a file always be reloaded when it is changed, or will a restart of the application be required? Thanks, Steve
> You said that this will happen when in development. What is the behavior in > production? Will a file always be reloaded when it is changed, or will a > restart of the application be required?In production, the fcgi process/webrick server must be restarted.