Difference between the three rails development modes

What is the difference between the three modes in rails like: -

 In development mode, Rails reloads models each time a browser sends in a request,
 so the model will always reflect the current database schema.

      

EDIT I was asking about other differences. I mentioned one, I was looking for another list of differences ... !!

+2


a source to share


2 answers


It comes down to performance and stability. In production mode, the model is cached in memory, which means that after they have been read once, the files do not have to be read again, which has an obvious speed benefit. This means that if you change the ruby ​​file (for example app / models / page.rb) where the model was defined, that change will not be received until the next reboot.

By default, the following line is located in config / environment / production.rb:

config.cache_classes = true

      

It is assumed that when you are in production, you will not change your code except through release or deployment. If you want to clear the cache, you need to restart the application.



The development environment will reload your models every time it receives a request. This is controlled by the following default line in config / environment / development.rb:

config.cache_classes = false

      

In terms of the "third" mode, I am assuming you mean the test mode. This also caches the models by default (see Config / environment / test.rb), again with the assumption that you won't change your codebase in the middle of a test run.

Btw, it's not just models - I'm sure this option covers any classes found in the "app" directory. In addition, you will find that even in design mode, classes located elsewhere in the application (for example, "lib") cannot be changed without restarting the application.

+7


a source


The behavior of the three modes is configurable in:

rails_app/config/environments/[production|development|test].rb



So it depends on your configuration how different modes are.

+5


a source







All Articles