This post originated from an RSS feed registered with Ruby Buzz
by rwdaigle.
Original Post: What's New in Edge Rails: Cleaning up Your Plugins
Feed Title: Ryan's Scraps
Feed URL: http://feeds.feedburner.com/RyansScraps
Feed Description: Ryan Daigle's various technically inclined rants along w/ the "What's new in Edge Rails" series.
Changesets 4427 and 4440 provide an uninstall hook for plugins. Previously, all that was done when a plugin was uninstalled via ruby script/plugin remove plugin_name was that the plugin directory was deleted.
Now, Rails allows plugin developers to do specific cleanup tasks on uninstall by providing an uninstall hook. This is useful when the plugin provides specific CSS, view or DB resources that can be safely removed when the plugin is uninstalled.
All plugins need to do is provide an uninstall.rb file in the plugin directory (similar to the standard init.rb install file) with the teardown logic specific to that plugin. The plugin template now provides a uninstall.rb file too, so everything is in place for the plugin to properly clean up after itself.