提交 d9615928 编写于 作者: J Jeremy Kemper

Merge branch 'master' of git@github.com:rails/rails

...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures') FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
ActionMailer::Base.template_root = FIXTURE_LOAD_PATH ActionMailer::Base.template_root = FIXTURE_LOAD_PATH
ActionMailer::Base.template_root.load
class MockSMTP class MockSMTP
def self.deliveries def self.deliveries
......
...@@ -869,7 +869,7 @@ def render(options = nil, extra_options = {}, &block) #:doc: ...@@ -869,7 +869,7 @@ def render(options = nil, extra_options = {}, &block) #:doc:
validate_render_arguments(options, extra_options, block_given?) validate_render_arguments(options, extra_options, block_given?)
if options.nil? if options.nil?
options = { :template => default_template.filename, :layout => true } options = { :template => default_template, :layout => true }
elsif options == :update elsif options == :update
options = extra_options.merge({ :update => true }) options = extra_options.merge({ :update => true })
elsif options.is_a?(String) || options.is_a?(Symbol) elsif options.is_a?(String) || options.is_a?(Symbol)
...@@ -1125,7 +1125,7 @@ def stale?(options) ...@@ -1125,7 +1125,7 @@ def stale?(options)
end end
# Sets the etag, last_modified, or both on the response and renders a # Sets the etag, last_modified, or both on the response and renders a
# "304 Not Modified" response if the request is already fresh. # "304 Not Modified" response if the request is already fresh.
# #
# Example: # Example:
# #
...@@ -1133,8 +1133,8 @@ def stale?(options) ...@@ -1133,8 +1133,8 @@ def stale?(options)
# @article = Article.find(params[:id]) # @article = Article.find(params[:id])
# fresh_when(:etag => @article, :last_modified => @article.created_at.utc) # fresh_when(:etag => @article, :last_modified => @article.created_at.utc)
# end # end
# #
# This will render the show template if the request isn't sending a matching etag or # This will render the show template if the request isn't sending a matching etag or
# If-Modified-Since header and just a "304 Not Modified" response if there's a match. # If-Modified-Since header and just a "304 Not Modified" response if there's a match.
def fresh_when(options) def fresh_when(options)
options.assert_valid_keys(:etag, :last_modified) options.assert_valid_keys(:etag, :last_modified)
...@@ -1239,7 +1239,7 @@ def log_processing ...@@ -1239,7 +1239,7 @@ def log_processing
log_processing_for_parameters log_processing_for_parameters
end end
end end
def log_processing_for_request_id def log_processing_for_request_id
request_id = "\n\nProcessing #{self.class.name}\##{action_name} " request_id = "\n\nProcessing #{self.class.name}\##{action_name} "
request_id << "to #{params[:format]} " if params[:format] request_id << "to #{params[:format]} " if params[:format]
...@@ -1251,7 +1251,7 @@ def log_processing_for_request_id ...@@ -1251,7 +1251,7 @@ def log_processing_for_request_id
def log_processing_for_parameters def log_processing_for_parameters
parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params.dup parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params.dup
parameters = parameters.except!(:controller, :action, :format, :_method) parameters = parameters.except!(:controller, :action, :format, :_method)
logger.info " Parameters: #{parameters.inspect}" unless parameters.empty? logger.info " Parameters: #{parameters.inspect}" unless parameters.empty?
end end
......
...@@ -38,8 +38,8 @@ module Rescue ...@@ -38,8 +38,8 @@ module Rescue
'ActionView::TemplateError' => 'template_error' 'ActionView::TemplateError' => 'template_error'
} }
RESCUES_TEMPLATE_PATH = ActionView::PathSet::Path.new( RESCUES_TEMPLATE_PATH = ActionView::Template::EagerPath.new(
File.join(File.dirname(__FILE__), "templates"), true) File.join(File.dirname(__FILE__), "templates"))
def self.included(base) #:nodoc: def self.included(base) #:nodoc:
base.cattr_accessor :rescue_responses base.cattr_accessor :rescue_responses
......
...@@ -70,11 +70,12 @@ def bind(key, value) ...@@ -70,11 +70,12 @@ def bind(key, value)
top[-1][key] = value top[-1][key] = value
else else
top << {key => value}.with_indifferent_access top << {key => value}.with_indifferent_access
push top.last
value = top[key]
end end
push top.last
return top[key]
else else
top << value top << value
return value
end end
elsif top.is_a? Hash elsif top.is_a? Hash
key = CGI.unescape(key) key = CGI.unescape(key)
...@@ -84,12 +85,10 @@ def bind(key, value) ...@@ -84,12 +85,10 @@ def bind(key, value)
else else
raise ArgumentError, "Don't know what to do: top is #{top.inspect}" raise ArgumentError, "Don't know what to do: top is #{top.inspect}"
end end
return value
end end
def type_conflict!(klass, value) def type_conflict!(klass, value)
raise TypeError, "Conflicting types for parameter containers. Expected an instance of #{klass} but found an instance of #{value.class}. This can be caused by colliding Array and Hash parameters like qs[]=value&qs[key]=value. (The parameters received were #{value.inspect}.)" raise TypeError, "Conflicting types for parameter containers. Expected an instance of #{klass} but found an instance of #{value.class}. This can be caused by colliding Array and Hash parameters like qs[]=value&qs[key]=value. (The parameters received were #{value.inspect}.)"
end end
end end
end end
\ No newline at end of file
...@@ -225,7 +225,7 @@ def view_paths=(paths) ...@@ -225,7 +225,7 @@ def view_paths=(paths)
end end
# Returns the result of a render that's dictated by the options hash. The primary options are: # Returns the result of a render that's dictated by the options hash. The primary options are:
# #
# * <tt>:partial</tt> - See ActionView::Partials. # * <tt>:partial</tt> - See ActionView::Partials.
# * <tt>:update</tt> - Calls update_page with the block given. # * <tt>:update</tt> - Calls update_page with the block given.
# * <tt>:file</tt> - Renders an explicit template file (this used to be the old default), add :locals to pass in those. # * <tt>:file</tt> - Renders an explicit template file (this used to be the old default), add :locals to pass in those.
......
...@@ -12,7 +12,7 @@ def initialize(source, type = nil) ...@@ -12,7 +12,7 @@ def initialize(source, type = nil)
private private
# Always recompile inline templates # Always recompile inline templates
def recompile?(local_assigns) def recompile?
true true
end end
end end
......
...@@ -2,7 +2,7 @@ module ActionView #:nodoc: ...@@ -2,7 +2,7 @@ module ActionView #:nodoc:
class PathSet < Array #:nodoc: class PathSet < Array #:nodoc:
def self.type_cast(obj) def self.type_cast(obj)
if obj.is_a?(String) if obj.is_a?(String)
Path.new(obj) Template::EagerPath.new(obj)
else else
obj obj
end end
...@@ -32,111 +32,6 @@ def unshift(*objs) ...@@ -32,111 +32,6 @@ def unshift(*objs)
super(*objs.map { |obj| self.class.type_cast(obj) }) super(*objs.map { |obj| self.class.type_cast(obj) })
end end
class Path #:nodoc:
attr_reader :path, :paths
delegate :hash, :inspect, :to => :path
def initialize(path, load = false)
raise ArgumentError, "path already is a Path class" if path.is_a?(Path)
@path = path.freeze
reload! if load
end
def to_s
if defined?(RAILS_ROOT)
path.to_s.sub(/^#{Regexp.escape(File.expand_path(RAILS_ROOT))}\//, '')
else
path.to_s
end
end
def to_str
path.to_str
end
def ==(path)
to_str == path.to_str
end
def eql?(path)
to_str == path.to_str
end
# Returns a ActionView::Template object for the given path string. The
# input path should be relative to the view path directory,
# +hello/index.html.erb+. This method also has a special exception to
# match partial file names without a handler extension. So
# +hello/index.html+ will match the first template it finds with a
# known template extension, +hello/index.html.erb+. Template extensions
# should not be confused with format extensions +html+, +js+, +xml+,
# etc. A format must be supplied to match a formated file. +hello/index+
# will never match +hello/index.html.erb+.
#
# This method also has two different implementations, one that is "lazy"
# and makes file system calls every time and the other is cached,
# "eager" which looks up the template in an in memory index. The "lazy"
# version is designed for development where you want to automatically
# find new templates between requests. The "eager" version is designed
# for production mode and it is much faster but requires more time
# upfront to build the file index.
def [](path)
if loaded?
@paths[path]
else
Dir.glob("#{@path}/#{path}*").each do |file|
template = create_template(file)
if template.accessible_paths.include?(path)
return template
end
end
nil
end
end
def loaded?
@loaded ? true : false
end
def load
reload! unless loaded?
self
end
# Rebuild load path directory cache
def reload!
@paths = {}
templates_in_path do |template|
template.load!
template.accessible_paths.each do |path|
@paths[path] = template
end
end
@paths.freeze
@loaded = true
end
private
def templates_in_path
(Dir.glob("#{@path}/**/*/**") | Dir.glob("#{@path}/**")).each do |file|
yield create_template(file) unless File.directory?(file)
end
end
def create_template(file)
Template.new(file.split("#{self}/").last, self)
end
end
def load
each { |path| path.load }
end
def reload!
each { |path| path.reload! }
end
def find_template(original_template_path, format = nil) def find_template(original_template_path, format = nil)
return original_template_path if original_template_path.respond_to?(:render) return original_template_path if original_template_path.respond_to?(:render)
template_path = original_template_path.sub(/^\//, '') template_path = original_template_path.sub(/^\//, '')
......
...@@ -60,7 +60,7 @@ def method_name(local_assigns) ...@@ -60,7 +60,7 @@ def method_name(local_assigns)
def compile(local_assigns) def compile(local_assigns)
render_symbol = method_name(local_assigns) render_symbol = method_name(local_assigns)
if recompile?(render_symbol) if !Base::CompiledTemplates.method_defined?(render_symbol) || recompile?
compile!(render_symbol, local_assigns) compile!(render_symbol, local_assigns)
end end
end end
...@@ -89,11 +89,8 @@ def #{render_symbol}(local_assigns) ...@@ -89,11 +89,8 @@ def #{render_symbol}(local_assigns)
end end
end end
# Method to check whether template compilation is necessary. def recompile?
# The template will be compiled if the file has not been compiled yet, or false
# if local_assigns has a new key, which isn't supported by the compiled code yet.
def recompile?(symbol)
!Base::CompiledTemplates.method_defined?(symbol) || !loaded?
end end
end end
end end
module ActionView #:nodoc: module ActionView #:nodoc:
class Template class Template
class Path
attr_reader :path, :paths
delegate :hash, :inspect, :to => :path
def initialize(path)
raise ArgumentError, "path already is a Path class" if path.is_a?(Path)
@path = path.freeze
end
def to_s
if defined?(RAILS_ROOT)
path.to_s.sub(/^#{Regexp.escape(File.expand_path(RAILS_ROOT))}\//, '')
else
path.to_s
end
end
def to_str
path.to_str
end
def ==(path)
to_str == path.to_str
end
def eql?(path)
to_str == path.to_str
end
# Returns a ActionView::Template object for the given path string. The
# input path should be relative to the view path directory,
# +hello/index.html.erb+. This method also has a special exception to
# match partial file names without a handler extension. So
# +hello/index.html+ will match the first template it finds with a
# known template extension, +hello/index.html.erb+. Template extensions
# should not be confused with format extensions +html+, +js+, +xml+,
# etc. A format must be supplied to match a formated file. +hello/index+
# will never match +hello/index.html.erb+.
def [](path)
templates_in_path do |template|
if template.accessible_paths.include?(path)
return template
end
end
nil
end
private
def templates_in_path
(Dir.glob("#{@path}/**/*/**") | Dir.glob("#{@path}/**")).each do |file|
yield create_template(file) unless File.directory?(file)
end
end
def create_template(file)
Template.new(file.split("#{self}/").last, self)
end
end
class EagerPath < Path
def initialize(path)
super
@paths = {}
templates_in_path do |template|
template.load!
template.accessible_paths.each do |path|
@paths[path] = template
end
end
@paths.freeze
end
def [](path)
@paths[path]
end
end
extend TemplateHandlers extend TemplateHandlers
extend ActiveSupport::Memoizable extend ActiveSupport::Memoizable
include Renderable include Renderable
...@@ -115,13 +193,12 @@ def stale? ...@@ -115,13 +193,12 @@ def stale?
File.mtime(filename) > mtime File.mtime(filename) > mtime
end end
def loaded? def recompile?
@loaded !@cached
end end
def load! def load!
@loaded = true @cached = true
compile({})
freeze freeze
end end
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures') FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
ActionController::Base.view_paths = FIXTURE_LOAD_PATH ActionController::Base.view_paths = FIXTURE_LOAD_PATH
ActionController::Base.view_paths.load
def uses_mocha(test_name) def uses_mocha(test_name)
yield yield
......
...@@ -441,6 +441,7 @@ def test_deep_query_string_with_array ...@@ -441,6 +441,7 @@ def test_deep_query_string_with_array
def test_deep_query_string_with_array_of_hash def test_deep_query_string_with_array_of_hash
assert_equal({'x' => {'y' => [{'z' => '10'}]}}, ActionController::RequestParser.parse_query_parameters('x[y][][z]=10')) assert_equal({'x' => {'y' => [{'z' => '10'}]}}, ActionController::RequestParser.parse_query_parameters('x[y][][z]=10'))
assert_equal({'x' => {'y' => [{'z' => '10', 'w' => '10'}]}}, ActionController::RequestParser.parse_query_parameters('x[y][][z]=10&x[y][][w]=10')) assert_equal({'x' => {'y' => [{'z' => '10', 'w' => '10'}]}}, ActionController::RequestParser.parse_query_parameters('x[y][][z]=10&x[y][][w]=10'))
assert_equal({'x' => {'y' => [{'z' => '10', 'v' => {'w' => '10'}}]}}, ActionController::RequestParser.parse_query_parameters('x[y][][z]=10&x[y][][v][w]=10'))
end end
def test_deep_query_string_with_array_of_hashes_with_one_pair def test_deep_query_string_with_array_of_hashes_with_one_pair
......
...@@ -31,7 +31,7 @@ def test_compiled_template_will_not_be_recompiled_when_rendered_with_identical_l ...@@ -31,7 +31,7 @@ def test_compiled_template_will_not_be_recompiled_when_rendered_with_identical_l
end end
def test_compiled_template_will_always_be_recompiled_when_template_is_not_cached def test_compiled_template_will_always_be_recompiled_when_template_is_not_cached
ActionView::Template.any_instance.expects(:loaded?).times(3).returns(false) ActionView::Template.any_instance.expects(:recompile?).times(3).returns(true)
assert_equal 0, @compiled_templates.instance_methods.size assert_equal 0, @compiled_templates.instance_methods.size
assert_equal "Hello world!", render(:file => "#{FIXTURE_LOAD_PATH}/test/hello_world.erb") assert_equal "Hello world!", render(:file => "#{FIXTURE_LOAD_PATH}/test/hello_world.erb")
ActionView::Template.any_instance.expects(:compile!).times(3) ActionView::Template.any_instance.expects(:compile!).times(3)
...@@ -62,13 +62,14 @@ def render(*args) ...@@ -62,13 +62,14 @@ def render(*args)
def render_with_cache(*args) def render_with_cache(*args)
view_paths = ActionController::Base.view_paths view_paths = ActionController::Base.view_paths
assert view_paths.first.loaded? assert_equal ActionView::Template::EagerPath, view_paths.first.class
ActionView::Base.new(view_paths, {}).render(*args) ActionView::Base.new(view_paths, {}).render(*args)
end end
def render_without_cache(*args) def render_without_cache(*args)
view_paths = ActionView::Base.process_view_paths(FIXTURE_LOAD_PATH) path = ActionView::Template::Path.new(FIXTURE_LOAD_PATH)
assert !view_paths.first.loaded? view_paths = ActionView::Base.process_view_paths(path)
assert_equal ActionView::Template::Path, view_paths.first.class
ActionView::Base.new(view_paths, {}).render(*args) ActionView::Base.new(view_paths, {}).render(*args)
end end
......
...@@ -197,7 +197,7 @@ class CachedViewRenderTest < Test::Unit::TestCase ...@@ -197,7 +197,7 @@ class CachedViewRenderTest < Test::Unit::TestCase
# Ensure view path cache is primed # Ensure view path cache is primed
def setup def setup
view_paths = ActionController::Base.view_paths view_paths = ActionController::Base.view_paths
assert view_paths.first.loaded? assert_equal ActionView::Template::EagerPath, view_paths.first.class
setup_view(view_paths) setup_view(view_paths)
end end
end end
...@@ -208,8 +208,9 @@ class LazyViewRenderTest < Test::Unit::TestCase ...@@ -208,8 +208,9 @@ class LazyViewRenderTest < Test::Unit::TestCase
# Test the same thing as above, but make sure the view path # Test the same thing as above, but make sure the view path
# is not eager loaded # is not eager loaded
def setup def setup
view_paths = ActionView::Base.process_view_paths(FIXTURE_LOAD_PATH) path = ActionView::Template::Path.new(FIXTURE_LOAD_PATH)
assert !view_paths.first.loaded? view_paths = ActionView::Base.process_view_paths(path)
assert_equal ActionView::Template::Path, view_paths.first.class
setup_view(view_paths) setup_view(view_paths)
end end
end end
...@@ -195,7 +195,7 @@ def preload_has_and_belongs_to_many_association(records, reflection, preload_opt ...@@ -195,7 +195,7 @@ def preload_has_and_belongs_to_many_association(records, reflection, preload_opt
def preload_has_one_association(records, reflection, preload_options={}) def preload_has_one_association(records, reflection, preload_options={})
return if records.first.send("loaded_#{reflection.name}?") return if records.first.send("loaded_#{reflection.name}?")
id_to_record_map, ids = construct_id_map(records) id_to_record_map, ids = construct_id_map(records, reflection.options[:primary_key])
options = reflection.options options = reflection.options
records.each {|record| record.send("set_#{reflection.name}_target", nil)} records.each {|record| record.send("set_#{reflection.name}_target", nil)}
if options[:through] if options[:through]
...@@ -229,7 +229,7 @@ def preload_has_many_association(records, reflection, preload_options={}) ...@@ -229,7 +229,7 @@ def preload_has_many_association(records, reflection, preload_options={})
options = reflection.options options = reflection.options
primary_key_name = reflection.through_reflection_primary_key_name primary_key_name = reflection.through_reflection_primary_key_name
id_to_record_map, ids = construct_id_map(records, primary_key_name) id_to_record_map, ids = construct_id_map(records, primary_key_name || reflection.options[:primary_key])
records.each {|record| record.send(reflection.name).loaded} records.each {|record| record.send(reflection.name).loaded}
if options[:through] if options[:through]
......
...@@ -22,7 +22,7 @@ def initialize(reflection) ...@@ -22,7 +22,7 @@ def initialize(reflection)
through_reflection = reflection.through_reflection through_reflection = reflection.through_reflection
source_reflection_names = reflection.source_reflection_names source_reflection_names = reflection.source_reflection_names
source_associations = reflection.through_reflection.klass.reflect_on_all_associations.collect { |a| a.name.inspect } source_associations = reflection.through_reflection.klass.reflect_on_all_associations.collect { |a| a.name.inspect }
super("Could not find the source association(s) #{source_reflection_names.collect(&:inspect).to_sentence :connector => 'or'} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => <name>'. Is it one of #{source_associations.to_sentence :connector => 'or'}?") super("Could not find the source association(s) #{source_reflection_names.collect(&:inspect).to_sentence :two_words_connector => ' or ', :last_word_connector => ', or '} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => <name>'. Is it one of #{source_associations.to_sentence :two_words_connector => ' or ', :last_word_connector => ', or '}?")
end end
end end
...@@ -2171,7 +2171,7 @@ def association_join ...@@ -2171,7 +2171,7 @@ def association_join
aliased_table_name, aliased_table_name,
foreign_key, foreign_key,
parent.aliased_table_name, parent.aliased_table_name,
parent.primary_key reflection.options[:primary_key] || parent.primary_key
] ]
end end
when :belongs_to when :belongs_to
......
...@@ -180,7 +180,10 @@ def set_belongs_to_association_for(record) ...@@ -180,7 +180,10 @@ def set_belongs_to_association_for(record)
record["#{@reflection.options[:as]}_id"] = @owner.id unless @owner.new_record? record["#{@reflection.options[:as]}_id"] = @owner.id unless @owner.new_record?
record["#{@reflection.options[:as]}_type"] = @owner.class.base_class.name.to_s record["#{@reflection.options[:as]}_type"] = @owner.class.base_class.name.to_s
else else
record[@reflection.primary_key_name] = @owner.id unless @owner.new_record? unless @owner.new_record?
primary_key = @reflection.options[:primary_key] || :id
record[@reflection.primary_key_name] = @owner.send(primary_key)
end
end end
end end
......
...@@ -402,6 +402,10 @@ def rename_table(name, new_name) ...@@ -402,6 +402,10 @@ def rename_table(name, new_name)
end end
def add_column(table_name, column_name, type, options = {}) #:nodoc: def add_column(table_name, column_name, type, options = {}) #:nodoc:
if @connection.respond_to?(:transaction_active?) && @connection.transaction_active?
raise StatementInvalid, 'Cannot add columns to a SQLite database while inside a transaction'
end
alter_table(table_name) do |definition| alter_table(table_name) do |definition|
definition.column(column_name, type, options) definition.column(column_name, type, options)
end end
......
...@@ -786,4 +786,37 @@ def test_preload_has_many_uses_exclusive_scope ...@@ -786,4 +786,37 @@ def test_preload_has_many_uses_exclusive_scope
assert_equal Person.find(person.id).agents, person.agents assert_equal Person.find(person.id).agents, person.agents
end end
end end
def test_preload_has_many_using_primary_key
expected = Firm.find(:first).clients_using_primary_key.to_a
firm = Firm.find :first, :include => :clients_using_primary_key
assert_no_queries do
assert_equal expected, firm.clients_using_primary_key
end
end
def test_include_has_many_using_primary_key
expected = Firm.find(1).clients_using_primary_key.sort_by &:name
firm = Firm.find 1, :include => :clients_using_primary_key, :order => 'clients_using_primary_keys_companies.name'
assert_no_queries do
assert_equal expected, firm.clients_using_primary_key
end
end
def test_preload_has_one_using_primary_key
expected = Firm.find(:first).account_using_primary_key
firm = Firm.find :first, :include => :account_using_primary_key
assert_no_queries do
assert_equal expected, firm.account_using_primary_key
end
end
def test_include_has_one_using_primary_key
expected = Firm.find(1).account_using_primary_key
firm = Firm.find(:all, :include => :account_using_primary_key, :order => 'accounts.id').detect {|f| f.id == 1}
assert_no_queries do
assert_equal expected, firm.account_using_primary_key
end
end
end end
...@@ -1115,5 +1115,11 @@ def test_respond_to_private_class_methods ...@@ -1115,5 +1115,11 @@ def test_respond_to_private_class_methods
assert !client_association.respond_to?(:private_method) assert !client_association.respond_to?(:private_method)
assert client_association.respond_to?(:private_method, true) assert client_association.respond_to?(:private_method, true)
end end
def test_creating_using_primary_key
firm = Firm.find(:first)
client = firm.clients_using_primary_key.create!(:name => 'test')
assert_equal firm.name, client.firm_name
end
end end
...@@ -254,7 +254,7 @@ def test_rand_should_select_a_random_object_from_proxy ...@@ -254,7 +254,7 @@ def test_rand_should_select_a_random_object_from_proxy
end end
def test_should_use_where_in_query_for_named_scope def test_should_use_where_in_query_for_named_scope
assert_equal Developer.find_all_by_name('Jamis'), Developer.find_all_by_id(Developer.jamises) assert_equal Developer.find_all_by_name('Jamis').to_set, Developer.find_all_by_id(Developer.jamises).to_set
end end
def test_size_should_use_count_when_results_are_not_loaded def test_size_should_use_count_when_results_are_not_loaded
......
...@@ -370,8 +370,9 @@ def load_observers ...@@ -370,8 +370,9 @@ def load_observers
def load_view_paths def load_view_paths
if configuration.frameworks.include?(:action_view) if configuration.frameworks.include?(:action_view)
if configuration.cache_classes if configuration.cache_classes
ActionController::Base.view_paths.load if configuration.frameworks.include?(:action_controller) view_path = ActionView::Template::EagerPath.new(configuration.view_path)
ActionMailer::Base.template_root.load if configuration.frameworks.include?(:action_mailer) ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller)
ActionMailer::Base.template_root = view_path if configuration.frameworks.include?(:action_mailer)
end end
end end
end end
...@@ -473,7 +474,7 @@ def initialize_framework_logging ...@@ -473,7 +474,7 @@ def initialize_framework_logging
# set to use Configuration#view_path. # set to use Configuration#view_path.
def initialize_framework_views def initialize_framework_views
if configuration.frameworks.include?(:action_view) if configuration.frameworks.include?(:action_view)
view_path = ActionView::PathSet::Path.new(configuration.view_path, false) view_path = ActionView::Template::Path.new(configuration.view_path)
ActionMailer::Base.template_root ||= view_path if configuration.frameworks.include?(:action_mailer) ActionMailer::Base.template_root ||= view_path if configuration.frameworks.include?(:action_mailer)
ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller) && ActionController::Base.view_paths.empty? ActionController::Base.view_paths = view_path if configuration.frameworks.include?(:action_controller) && ActionController::Base.view_paths.empty?
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册