Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
fixed unloadable/Dependencies bug in the engines controllers caused b…
Browse files Browse the repository at this point in the history
…y subclassing ApplicationController. The solution is to explicitly call unloadable in any such controllers, and it's by design.
  • Loading branch information
Josh Adams committed Sep 9, 2008
1 parent 08806ba commit 679f9c7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 31 deletions.
@@ -1,4 +1,6 @@
class ContentSectionsController < ApplicationController
unloadable # This is required if you subclass a controller provided by the base rails app

layout 'admin'
before_filter :load_content_section, :only => [:show, :edit, :update]
protected
Expand Down
@@ -1,4 +1,6 @@
class PhotoAlbumsController < ApplicationController
unloadable # This is required if you subclass a controller provided by the base rails app

before_filter :load_photo_album, :only => [:show, :update]
before_filter :load_photos, :only => [:show]
layout 'admin'
Expand Down
@@ -1,7 +1,6 @@
Ansuz::JAdams::PhotoAlbumPhoto
Ansuz::JAdams::PhotoAlbumPhoto

class PhotosController < ApplicationController
unloadable # This is required if you subclass a controller provided by the base rails app

before_filter :load_photo_album
before_filter :load_new_photo, :only => [:new, :create]
protected
Expand Down
56 changes: 28 additions & 28 deletions vendor/plugins/savage_beast/init.rb
@@ -1,11 +1,11 @@
ActionView::Base.send :include, SavageBeast::AuthenticationSystem
ActionController::Base.send :include, SavageBeast::AuthenticationSystem

# FIX for engines model reloading issue in development mode
if ENV['RAILS_ENV'] != 'production'
load_paths.each do |path|
Dependencies.load_once_paths.delete(path)
end
# FIX for engines model reloading issue in development mode
if ENV['RAILS_ENV'] != 'production'
load_paths.each do |path|
Dependencies.load_once_paths.delete(path)
end
end

# Include your application configuration below
Expand All @@ -21,34 +21,34 @@ class << self; attr_reader :#{method_name}; end
EOS
end
end


# All this is given in engines plugin
# Define the means by which to add our own routing to Rails' routing
class ActionController::Routing::RouteSet::Mapper
def from_plugin(name)
eval File.read(File.join(RAILS_ROOT, "vendor/plugins/#{name}/routes.rb"))

# All this is given in engines plugin
# Define the means by which to add our own routing to Rails' routing
class ActionController::Routing::RouteSet::Mapper
def from_plugin(name)
eval File.read(File.join(RAILS_ROOT, "vendor/plugins/#{name}/routes.rb"))
end
end

#--------------------------------------------------------------------------------
# Uncommenting this section of code allows the plugin to work without the engines plugin
# installed. Just need to copy the helpers into the lib directory.
# So why use Engines?
# It allows controller methods to be overridden
# It gives an easy way to access images
# It allows controller views to be overridden
#--------------------------------------------------------------------------------
# Add our models and controllers to the application
# Stolen from http://weblog.techno-weenie.net/2007/1/24/understanding-the-rails-initialization-process
# You can't use config.load_paths because #set_autoload_paths has already been called in the Rails Initialization process
#models_path = File.join(directory, 'app', 'models')
#$LOAD_PATH << models_path

#--------------------------------------------------------------------------------
# Uncommenting this section of code allows the plugin to work without the engines plugin
# installed. Just need to copy the helpers into the lib directory.
# So why use Engines?
# It allows controller methods to be overridden
# It gives an easy way to access images
# It allows controller views to be overridden
#--------------------------------------------------------------------------------
# Add our models and controllers to the application
# Stolen from http://weblog.techno-weenie.net/2007/1/24/understanding-the-rails-initialization-process
# You can't use config.load_paths because #set_autoload_paths has already been called in the Rails Initialization process
#models_path = File.join(directory, 'app', 'models')
#$LOAD_PATH << models_path
#Dependencies.load_paths << models_path

#controller_path = File.join(directory, 'app', 'controllers')
#$LOAD_PATH << controller_path
#Dependencies.load_paths << controller_path
#controller_path = File.join(directory, 'app', 'controllers')
#$LOAD_PATH << controller_path
#Dependencies.load_paths << controller_path
#config.controller_paths << controller_path

#view_path = File.join(directory, 'app', 'views')
Expand Down

0 comments on commit 679f9c7

Please sign in to comment.