mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Ensure helpers work from configured path.
This commit is contained in:
@@ -7,7 +7,6 @@ module ActionController
|
||||
include AbstractController::Translation
|
||||
|
||||
include ActionController::Helpers
|
||||
helper :all # By default, all helpers should be included
|
||||
|
||||
include ActionController::HideActions
|
||||
include ActionController::UrlFor
|
||||
@@ -67,6 +66,7 @@ module ActionController
|
||||
def self.inherited(klass)
|
||||
::ActionController::Base.subclasses << klass.to_s
|
||||
super
|
||||
klass.helper :all
|
||||
end
|
||||
|
||||
def self.subclasses
|
||||
|
||||
@@ -50,11 +50,8 @@ module ActionController
|
||||
include AbstractController::Helpers
|
||||
|
||||
included do
|
||||
# Set the default directory for helpers
|
||||
# TODO This should support multiple directories in order
|
||||
# to work with engines
|
||||
extlib_inheritable_accessor(:helpers_dir) do
|
||||
defined?(Rails.root) ? "#{Rails.root}/app/helpers" : "app/helpers"
|
||||
extlib_inheritable_accessor(:helpers_path) do
|
||||
defined?(Rails::Application) ? Rails::Application.paths.app.helpers.to_a : []
|
||||
end
|
||||
end
|
||||
|
||||
@@ -107,10 +104,15 @@ module ActionController
|
||||
raise e unless e.missing_name? "#{module_name}Helper"
|
||||
end
|
||||
|
||||
# Extract helper names from files in app/helpers/**/*.rb
|
||||
# Extract helper names from files in app/helpers/**/*_helper.rb
|
||||
def all_application_helpers
|
||||
extract = /^#{Regexp.quote(helpers_dir)}\/?(.*)_helper.rb$/
|
||||
Dir["#{helpers_dir}/**/*_helper.rb"].map { |file| file.sub extract, '\1' }
|
||||
helpers = []
|
||||
helpers_path.each do |path|
|
||||
extract = /^#{Regexp.quote(path)}\/?(.*)_helper.rb$/
|
||||
helpers += Dir["#{path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') }
|
||||
end
|
||||
helpers.uniq!
|
||||
helpers
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,8 +11,6 @@ module Rails
|
||||
autoload :Railties, 'rails/application/railties'
|
||||
autoload :RoutesReloader, 'rails/application/routes_reloader'
|
||||
|
||||
# TODO Check helpers works as expected
|
||||
# TODO Check routes namespaces
|
||||
# TODO Ensure production settings are read properly
|
||||
class << self
|
||||
private :new
|
||||
|
||||
@@ -15,6 +15,7 @@ module Rails
|
||||
paths = Rails::Paths::Root.new(@root)
|
||||
paths.app "app", :eager_load => true, :glob => "*"
|
||||
paths.app.controllers "app/controllers", :eager_load => true
|
||||
paths.app.helpers "app/helpers", :eager_load => true
|
||||
paths.app.metals "app/metal", :eager_load => true
|
||||
paths.app.views "app/views"
|
||||
paths.lib "lib", :load_path => true
|
||||
|
||||
Reference in New Issue
Block a user