mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Set only helpers_path on inherited hook in action_controller/railtie.rb and use helper(:all) just after that
This commit is contained in:
parent
8ec2175aee
commit
98ab4ded37
5 changed files with 17 additions and 38 deletions
|
@ -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 @@ module ActionMailer
|
|||
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 @@ module ActionController
|
|||
# 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 @@ module ActionController
|
|||
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 @@ module ActionController
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue