Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails: unloadable

Tags:

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.

like image 233
ma11hew28 Avatar asked Jul 28 '11 02:07

ma11hew28


1 Answers

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.

like image 163
Maurício Linhares Avatar answered Oct 02 '22 08:10

Maurício Linhares