Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
include Reloadable
3 Posts
include Reloadable

I am using include reloadable in one of my model files

This works fine in development env. but in production it fails, the changes are updated only when the server is restarted.

i found in an article that to enable this in production we have to make sure

Dependencies.mechanism is set to :load, by default it is set to :require in production ENV.

to set this to :load we have to edit production ENV file and set

config.cache_classes = false

but this is not recommended in production because it slows down the performance,

is there any other way I can use reloadable in production without sacrificing performance ?

Person
Forum Rating: 100
Sign In To Rate Post

Reloading provides for a more efficient development environment by allowing changes made to files to automatically be incorporated without having to constantly restart your development server process. The price paid, even in a development environment, is a slower response but that's a very small price to pay in development where files are changing constantly compared to the overall gain you get of not having to restart your server process every 42 seconds.

In production however, files aren't supposed to change much, so there shouldn't be a need for the server to constantly reload the same files over and over again. There's no way to bypass the performance hit that comes with reloading, just like there's no way to run your computer without consuming some electricity. That's just how it is. It is however standard procedure with a Rails application to restart the sever processes when a new version is deployed.

So, if your goal is to be able to deploy new versions of your application without restarting the server, then my answer is that you just need to accept that that's how it works. Restarting the server processes occasionally when deploying a new version is a small price to pay (especially when done automatically with tools like Capistrano) in comparison to the improved performance in production by not enabling reloading.

If however, some feature of your application depends on reloading to function properly outside of deploying new versions, then I suggest that you seriously rethink how that feature has been implemented and find a way to do it that doesn't require reloading.

Balaji, which version of Rails are you using? As of 1.3.0 (January 16th, 2007), Include Reloadable has been deprecated and does not work. See: http://weblog.rubyonrails.org/2006/8/11/reloading-revamped.

I agree with Jonathan though, production should not need this, unless I am missing something. What is the reason you want Reloadable?

3 Posts
Login to add your message