20

What does unloadable do?

I saw this in the pages controller of High Voltage by thoughtbot. thoughtbot blogs about unloadable, but am still unclear on what it does.

ma11hew28
  • 121,420
  • 116
  • 450
  • 651
  • As the accepted answer is no longer valid, could you could accept the other answer instead? Thanks. – GuruM Feb 28 '14 at 08:31
  • For those who are looking for blog this is the updated link. https://thoughtbot.com/blog/tips-for-writing-your-own-rails-engine – Gurpreet Singh Mar 04 '19 at 06:52

1 Answers1

45

It means that when you're running on an environment configured with cache_classes = false (like the development environment) these classes are going to be reloaded by Rails on every request, so you can place them inside your lib folder or inside a plugin and they will always be reloaded without you having to restart the app (as classes inside lib or plugins are not reloaded by rails on every request by default).

This is mostly useful when you're building a plugin and you would like to do live changes on it without having to go through the process of always restarting your app on every test.

You can see the unloadable method documentation here.

Maurício Linhares
  • 39,901
  • 14
  • 121
  • 158