Rails class caching / reloading and Engines

Plugins, Ruby on Rails Add comments

I’ve been playing around with Engines a bit at work, and I ran into an issue where I had to restart the server over and over due to class caching issues.

To make a long story short, I was able to force Rails to reload the particular engine I was using by adding the following to the engine’s init.rb:


%w(controllers helpers models views).each {|path| Dependencies.load_once_paths.delete File.join(File.dirname(__FILE__), 'app', path) }
Dependencies.load_once_paths.delete File.join(File.dirname(__FILE__), 'lib')

This worked with Rails 2.1 and an unknown version of the Engines plugin.

One Response to “Rails class caching / reloading and Engines”

  1. Dmitry Says:

    Thank you very much!
    I faced class cashing issue when tried to add my custom class to rails framework, then gave up and removed it, but still could initiate it! Thought that will drive me crazy, but now found you post.

    Thanks!

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in