Skip to content

Commit

Permalink
Improve missing template error messages a little bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jan 31, 2010
1 parent 48459c8 commit b3a0282
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions actionpack/lib/action_view/base.rb
Expand Up @@ -6,15 +6,20 @@ class ActionViewError < StandardError #: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

Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/paths.rb
Expand Up @@ -45,7 +45,7 @@ def find(path, details = {}, prefix = nil, partial = false)
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)
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/controller/mime_responds_test.rb
Expand Up @@ -499,7 +499,7 @@ def using_resource_with_responder

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

Expand Down

0 comments on commit b3a0282

Please sign in to comment.