Updated to support Rails 4 and Rails::Engine.