ma11hew28
ma11hew28

Reputation: 126319

Ruby on Rails: unloadable

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.

Upvotes: 20

Views: 6273

Answers (1)

Maurício Linhares
Maurício Linhares

Reputation: 40313

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.

Upvotes: 45

Related Questions