aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2011-11-19 07:38:22 -0800
committerYehuda Katz <wycats@gmail.com>2011-11-19 07:38:22 -0800
commitbc04455f1032166e66f5aef06ff2976173ac7da6 (patch)
treee39f5d5ef5034c820418d87b34d20e88d4c4cfa6 /actionpack/lib
parentfec85cf10d831ab90386a549ea558b0dd58a813f (diff)
parent771635e858e486e1e9f2d181b710d81205e6bb4e (diff)
downloadrails-bc04455f1032166e66f5aef06ff2976173ac7da6.tar.gz
rails-bc04455f1032166e66f5aef06ff2976173ac7da6.tar.bz2
rails-bc04455f1032166e66f5aef06ff2976173ac7da6.zip
Merge pull request #3695 from tobiassvn/partial_path_error
Meaningful errors for unexpected partial arguments. Fixes #3573
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/renderer/partial_renderer.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb
index 15cb9d0f76..54a0ba96ff 100644
--- a/actionpack/lib/action_view/renderer/partial_renderer.rb
+++ b/actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -366,8 +366,13 @@ module ActionView
path = if object.respond_to?(:to_partial_path)
object.to_partial_path
else
- ActiveSupport::Deprecation.warn "ActiveModel-compatible objects whose classes return a #model_name that responds to #partial_path are deprecated. Please respond to #to_partial_path directly instead."
- object.class.model_name.partial_path
+ klass = object.class
+ if klass.respond_to?(:model_name)
+ ActiveSupport::Deprecation.warn "ActiveModel-compatible objects whose classes return a #model_name that responds to #partial_path are deprecated. Please respond to #to_partial_path directly instead."
+ klass.model_name.partial_path
+ else
+ raise ArgumentError.new("'#{object.inspect}' is not an ActiveModel-compatible object that returns a valid partial path.")
+ end
end
@partial_names[path] ||= path.dup.tap do |object_path|