Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Raise a better error if anyone wants to create your own ActionView::H…

…elpers::Tags::Base child and do not implement the render method
  • Loading branch information...
commit 930245ef12fbbb0628c332d36bf09a33050d5b65 1 parent fcfe1fa
@rafaelfranca rafaelfranca authored
View
5 actionpack/lib/action_view/helpers/tags/base.rb
@@ -19,8 +19,9 @@ def initialize(object_name, method_name, template_object, options = {})
@auto_index = retrieve_autoindex(Regexp.last_match.pre_match) if Regexp.last_match
end
- def render(&block)
- raise "Abstract Method called"
+ # This is what child classes implement.
+ def render
+ raise NotImplementedError, "Subclasses must implement a render method"
end
private
View
8 actionpack/test/template/form_helper_test.rb
@@ -115,6 +115,14 @@ def url_for(object)
super
end
+ class FooTag < ActionView::Helpers::Tags::Base
+ def initialize; end
+ end
+
+ def test_tags_base_child_without_render_method
+ assert_raise(NotImplementedError) { FooTag.new.render }
+ end
+
def test_label
assert_dom_equal('<label for="post_title">Title</label>', label("post", "title"))
assert_dom_equal('<label for="post_title">The title goes here</label>', label("post", "title", "The title goes here"))
Please sign in to comment.
Something went wrong with that request. Please try again.