mirror of https://github.com/rails/rails
Improve missing template error messages a little bit.
This commit is contained in:
parent
48459c8278
commit
b3a028259f
|
@ -6,15 +6,20 @@ module ActionView #:nodoc:
|
|||
end
|
||||
|
||||
class MissingTemplate < ActionViewError #:nodoc:
|
||||
attr_reader :path, :action_name
|
||||
attr_reader :path
|
||||
|
||||
def initialize(paths, path, template_format = nil)
|
||||
def initialize(paths, path, details, partial)
|
||||
@path = path
|
||||
@action_name = path.split("/").last.split(".")[0...-1].join(".")
|
||||
full_template_path = path.include?('.') ? path : "#{path}.erb"
|
||||
display_paths = paths.compact.join(":")
|
||||
template_type = (path =~ /layouts/i) ? 'layout' : 'template'
|
||||
super("Missing #{template_type} #{full_template_path} in view path #{display_paths}")
|
||||
template_type = if partial
|
||||
"partial"
|
||||
elsif path =~ /layouts/i
|
||||
'layout'
|
||||
else
|
||||
'template'
|
||||
end
|
||||
|
||||
super("Missing #{template_type} #{path} with #{details.inspect} in view path #{display_paths}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ module ActionView #:nodoc:
|
|||
end
|
||||
end
|
||||
|
||||
raise ActionView::MissingTemplate.new(self, "#{prefix}/#{path} - #{details.inspect} - partial: #{!!partial}")
|
||||
raise ActionView::MissingTemplate.new(self, "#{prefix}/#{path}", details, partial)
|
||||
end
|
||||
|
||||
def exists?(path, extension = nil, prefix = nil, partial = false)
|
||||
|
|
|
@ -499,7 +499,7 @@ class RespondWithController < ActionController::Base
|
|||
|
||||
def using_resource_with_action
|
||||
respond_with(resource, :action => :foo) do |format|
|
||||
format.html { raise ActionView::MissingTemplate.new([], "method") }
|
||||
format.html { raise ActionView::MissingTemplate.new([], "foo/bar", {}, false) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue