In my journey to hopefully master Ruby on Rails, I’m amazed to see that many authors (in blogs or in books) most of whom are pretty expert in the field, choose to exit the Rails console completely (using CTRL+D) when they need to restart the environment (to clear up the objects in the memory, for example).
Instead there is a convenient method:
that you can type inside Rails console and it will reload the environment for you. No need to wait extra second to exit and reenter the console.
P.S. There might be a wisdom in not choosing
realod! which I might not be aware of. In that case please enlighten me in the comments.
It only reloads the code, no changes in the attributes of models
Anyway it’s fine if you’re debugging some code and want to see how changes play out.
Actually it does reflect the model changes. 🙂
I ran a migration after the first
Image.new. That removed the
reload!, unless this is not what you mean.
reload! only reloads application code, not configs or anything environment related