Ruby on Rails
HowToWritePluginWithModels

Rails does some sneaky stuff with ActiveRecord models each time it handles a new request in development mode.

Make sure your ActiveRecord models in your plugin redefine the reloadable? class method as follows:

def self.reloadable?; false end

This will prevent Rails from castrating your model of all its instance methods and variables. Just be careful you don’t keep stuff in there that’s tied to a request, because it won’t get cleared out.

Or name the model’s filename accordingly. If your model is FooBar, put it in vendor/plugins/your_plugin/lib/foo_bar.rb. This way Rails can reload it properly.