Permalink
Browse files

Set only helpers_path on inherited hook in action_controller/railtie.…

…rb and use helper(:all) just after that
  • Loading branch information...
1 parent 8ec2175 commit 98ab4ded376c3d04540bdbdfe6dbbf88c0738701 @drogus drogus committed Aug 23, 2010
@@ -1,7 +1,6 @@
require "action_mailer"
require "rails"
require "abstract_controller/railties/routes_helpers"
-require "action_mailer/railties/paths"
module ActionMailer
class Railtie < Rails::Railtie
@@ -12,13 +11,17 @@ class Railtie < Rails::Railtie
end
initializer "action_mailer.set_configs" do |app|
+ paths = app.config.paths
options = app.config.action_mailer
+ options.assets_dir ||= paths.public.to_a.first
+ options.javascripts_dir ||= paths.public.javascripts.to_a.first
+ options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
+
ActiveSupport.on_load(:action_mailer) do
include AbstractController::UrlFor
- include app.routes.mounted_helpers(:app)
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
- extend ::ActionMailer::Railties::Paths.with(app)
+ include app.routes.mounted_helpers(:app)
options.each { |k,v| send("#{k}=", v) }
end
end
@@ -1,26 +0,0 @@
-module ActionMailer
- module Railties
- module Paths
- def self.with(_app)
- Module.new do
- define_method(:inherited) do |klass|
- super(klass)
- if namespace = klass.parents.detect {|m| m.respond_to?(:_railtie) }
- app = namespace._railtie
- else
- app = _app
- end
-
- paths = app.config.paths
- options = app.config.action_mailer
-
- options.assets_dir ||= paths.public.to_a.first
- options.javascripts_dir ||= paths.public.javascripts.to_a.first
- options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
- options.each { |k,v| klass.send("#{k}=", v) }
- end
- end
- end
- end
- end
-end
@@ -221,11 +221,6 @@ def self.without_modules(*modules)
# Rails 2.x compatibility
include ActionController::Compatibility
- def self.inherited(klass)
- super
- klass.helper :all if klass.superclass == ActionController::Base
- end
-
ActiveSupport.run_load_hooks(:action_controller, self)
end
end
@@ -42,10 +42,19 @@ class Railtie < Rails::Railtie
end
initializer "action_controller.set_configs" do |app|
+ paths = app.config.paths
+ options = app.config.action_controller
+
+ options.assets_dir ||= paths.public.to_a.first
+ options.javascripts_dir ||= paths.public.javascripts.to_a.first
+ options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
+ options.page_cache_directory ||= paths.public.to_a.first
+
ActiveSupport.on_load(:action_controller) do
include app.routes.mounted_helpers(:app)
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
extend ::ActionController::Railties::Paths.with(app)
+ options.each { |k,v| send("#{k}=", v) }
end
end
@@ -14,12 +14,10 @@ def self.with(_app)
paths = app.config.paths
options = app.config.action_controller
- options.assets_dir ||= paths.public.to_a.first
- options.javascripts_dir ||= paths.public.javascripts.to_a.first
- options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
- options.page_cache_directory ||= paths.public.to_a.first
options.helpers_path ||= paths.app.helpers.to_a
options.each { |k,v| klass.send("#{k}=", v) }
+
+ klass.helper :all
end
end
end

0 comments on commit 98ab4de

Please sign in to comment.