提交 96d9691e 编写于 作者: J Joshua Peek

FormHelper#label_tag accepts :for option [encoded] [#38 state:resolved]

上级 b4c33711
require 'cgi' require 'cgi'
require 'action_view/helpers/date_helper' require 'action_view/helpers/date_helper'
require 'action_view/helpers/tag_helper' require 'action_view/helpers/tag_helper'
require 'action_view/helpers/form_tag_helper'
module ActionView module ActionView
module Helpers module Helpers
...@@ -51,7 +52,7 @@ module Helpers ...@@ -51,7 +52,7 @@ module Helpers
# #
# If the object name contains square brackets the id for the object will be inserted. For example: # If the object name contains square brackets the id for the object will be inserted. For example:
# #
# <%= text_field "person[]", "name" %> # <%= text_field "person[]", "name" %>
# #
# ...will generate the following ERb. # ...will generate the following ERb.
# #
...@@ -91,7 +92,7 @@ module FormHelper ...@@ -91,7 +92,7 @@ module FormHelper
# #
# Even further, the form_for method allows you to more easily escape the instance variable convention. So while the stand-alone # Even further, the form_for method allows you to more easily escape the instance variable convention. So while the stand-alone
# approach would require <tt>text_field :person, :name, :object => person</tt> # approach would require <tt>text_field :person, :name, :object => person</tt>
# to work with local variables instead of instance ones, the form_for calls remain the same. You simply declare once with # to work with local variables instead of instance ones, the form_for calls remain the same. You simply declare once with
# <tt>:person, person</tt> and all subsequent field calls save <tt>:person</tt> and <tt>:object => person</tt>. # <tt>:person, person</tt> and all subsequent field calls save <tt>:person</tt> and <tt>:object => person</tt>.
# #
# Also note that form_for doesn't create an exclusive scope. It's still possible to use both the stand-alone FormHelper methods # Also note that form_for doesn't create an exclusive scope. It's still possible to use both the stand-alone FormHelper methods
...@@ -149,7 +150,7 @@ module FormHelper ...@@ -149,7 +150,7 @@ module FormHelper
# ... # ...
# <% end %> # <% end %>
# #
# And for namespaced routes, like admin_post_url: # And for namespaced routes, like admin_post_url:
# #
# <% form_for([:admin, @post]) do |f| %> # <% form_for([:admin, @post]) do |f| %>
# ... # ...
...@@ -337,7 +338,7 @@ def password_field(object_name, method, options = {}) ...@@ -337,7 +338,7 @@ def password_field(object_name, method, options = {})
# hash with +options+. These options will be tagged onto the HTML as an HTML element attribute as in the example # hash with +options+. These options will be tagged onto the HTML as an HTML element attribute as in the example
# shown. # shown.
# #
# ==== Examples # ==== Examples
# hidden_field(:signup, :pass_confirm) # hidden_field(:signup, :pass_confirm)
# # => <input type="hidden" id="signup_pass_confirm" name="signup[pass_confirm]" value="#{@signup.pass_confirm}" /> # # => <input type="hidden" id="signup_pass_confirm" name="signup[pass_confirm]" value="#{@signup.pass_confirm}" />
# #
...@@ -404,7 +405,7 @@ def text_area(object_name, method, options = {}) ...@@ -404,7 +405,7 @@ def text_area(object_name, method, options = {})
# is set to 0 which is convenient for boolean values. Since HTTP standards say that unchecked checkboxes don't post anything, # is set to 0 which is convenient for boolean values. Since HTTP standards say that unchecked checkboxes don't post anything,
# we add a hidden value with the same name as the checkbox as a work around. # we add a hidden value with the same name as the checkbox as a work around.
# #
# ==== Examples # ==== Examples
# # Let's say that @post.validated? is 1: # # Let's say that @post.validated? is 1:
# check_box("post", "validated") # check_box("post", "validated")
# # => <input type="checkbox" id="post_validated" name="post[validated]" value="1" /> # # => <input type="checkbox" id="post_validated" name="post[validated]" value="1" />
...@@ -445,7 +446,7 @@ def radio_button(object_name, method, tag_value, options = {}) ...@@ -445,7 +446,7 @@ def radio_button(object_name, method, tag_value, options = {})
end end
class InstanceTag #:nodoc: class InstanceTag #:nodoc:
include Helpers::TagHelper include Helpers::TagHelper, Helpers::FormTagHelper
attr_reader :method_name, :object_name attr_reader :method_name, :object_name
...@@ -467,11 +468,12 @@ def initialize(object_name, method_name, template_object, local_binding = nil, o ...@@ -467,11 +468,12 @@ def initialize(object_name, method_name, template_object, local_binding = nil, o
end end
def to_label_tag(text = nil, options = {}) def to_label_tag(text = nil, options = {})
options = options.stringify_keys
name_and_id = options.dup name_and_id = options.dup
add_default_name_and_id(name_and_id) add_default_name_and_id(name_and_id)
options["for"] = name_and_id["id"] options["for"] ||= name_and_id["id"]
content = (text.blank? ? nil : text.to_s) || method_name.humanize content = (text.blank? ? nil : text.to_s) || method_name.humanize
content_tag("label", content, options) label_tag(name_and_id["id"], content, options)
end end
def to_input_field_tag(field_type, options = {}) def to_input_field_tag(field_type, options = {})
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast) alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast)
alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast) alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast)
alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast) alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast)
def new_record=(boolean) def new_record=(boolean)
@new_record = boolean @new_record = boolean
end end
def new_record? def new_record?
@new_record @new_record
end end
...@@ -36,13 +36,13 @@ class FormHelperTest < ActionView::TestCase ...@@ -36,13 +36,13 @@ class FormHelperTest < ActionView::TestCase
def setup def setup
@post = Post.new @post = Post.new
@comment = Comment.new @comment = Comment.new
def @post.errors() def @post.errors()
Class.new{ Class.new{
def on(field); "can't be empty" if field == "author_name"; end def on(field); "can't be empty" if field == "author_name"; end
def empty?() false end def empty?() false end
def count() 1 end def count() 1 end
def full_messages() [ "Author name can't be empty" ] end def full_messages() [ "Author name can't be empty" ] end
}.new }.new
end end
def @post.id; 123; end def @post.id; 123; end
def @post.id_before_type_cast; 123; end def @post.id_before_type_cast; 123; end
...@@ -72,11 +72,19 @@ def test_label ...@@ -72,11 +72,19 @@ def test_label
label("post", "title", nil, :class => 'title_label') label("post", "title", nil, :class => 'title_label')
) )
end end
def test_label_with_symbols def test_label_with_symbols
assert_dom_equal('<label for="post_title">Title</label>', label(:post, :title)) assert_dom_equal('<label for="post_title">Title</label>', label(:post, :title))
end end
def test_label_with_for_attribute_as_symbol
assert_dom_equal('<label for="my_for">Title</label>', label(:post, :title, nil, :for => "my_for"))
end
def test_label_with_for_attribute_as_string
assert_dom_equal('<label for="my_for">Title</label>', label(:post, :title, nil, "for" => "my_for"))
end
def test_text_field def test_text_field
assert_dom_equal( assert_dom_equal(
'<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />', text_field("post", "title") '<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />', text_field("post", "title")
...@@ -303,7 +311,7 @@ def test_form_for ...@@ -303,7 +311,7 @@ def test_form_for
_erbout.concat f.submit('Create post') _erbout.concat f.submit('Create post')
end end
expected = expected =
"<form action='http://www.example.com' id='create-post' method='post'>" + "<form action='http://www.example.com' id='create-post' method='post'>" +
"<label for='post_title'>Title</label>" + "<label for='post_title'>Title</label>" +
"<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
...@@ -325,7 +333,7 @@ def test_form_for_with_method ...@@ -325,7 +333,7 @@ def test_form_for_with_method
_erbout.concat f.check_box(:secret) _erbout.concat f.check_box(:secret)
end end
expected = expected =
"<form action='http://www.example.com' id='create-post' method='post'>" + "<form action='http://www.example.com' id='create-post' method='post'>" +
"<div style='margin:0;padding:0'><input name='_method' type='hidden' value='put' /></div>" + "<div style='margin:0;padding:0'><input name='_method' type='hidden' value='put' /></div>" +
"<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
...@@ -346,7 +354,7 @@ def test_form_for_without_object ...@@ -346,7 +354,7 @@ def test_form_for_without_object
_erbout.concat f.check_box(:secret) _erbout.concat f.check_box(:secret)
end end
expected = expected =
"<form action='http://www.example.com' id='create-post' method='post'>" + "<form action='http://www.example.com' id='create-post' method='post'>" +
"<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
"<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
...@@ -367,7 +375,7 @@ def test_form_for_with_index ...@@ -367,7 +375,7 @@ def test_form_for_with_index
_erbout.concat f.check_box(:secret) _erbout.concat f.check_box(:secret)
end end
expected = expected =
"<form action='http://www.example.com' method='post'>" + "<form action='http://www.example.com' method='post'>" +
"<label for=\"post_123_title\">Title</label>" + "<label for=\"post_123_title\">Title</label>" +
"<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" + "<input name='post[123][title]' size='30' type='text' id='post_123_title' value='Hello World' />" +
...@@ -423,7 +431,7 @@ def test_fields_for ...@@ -423,7 +431,7 @@ def test_fields_for
_erbout.concat f.check_box(:secret) _erbout.concat f.check_box(:secret)
end end
expected = expected =
"<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
"<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
"<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
...@@ -494,7 +502,7 @@ def test_fields_for_without_object ...@@ -494,7 +502,7 @@ def test_fields_for_without_object
_erbout.concat f.check_box(:secret) _erbout.concat f.check_box(:secret)
end end
expected = expected =
"<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
"<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
"<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
...@@ -511,7 +519,7 @@ def test_fields_for_with_only_object ...@@ -511,7 +519,7 @@ def test_fields_for_with_only_object
_erbout.concat f.check_box(:secret) _erbout.concat f.check_box(:secret)
end end
expected = expected =
"<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
"<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
"<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + "<input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
...@@ -548,7 +556,7 @@ def test_form_for_and_fields_for ...@@ -548,7 +556,7 @@ def test_form_for_and_fields_for
end end
end end
expected = expected =
"<form action='http://www.example.com' id='create-post' method='post'>" + "<form action='http://www.example.com' id='create-post' method='post'>" +
"<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
"<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
...@@ -571,7 +579,7 @@ def test_form_for_and_fields_for_with_object ...@@ -571,7 +579,7 @@ def test_form_for_and_fields_for_with_object
end end
end end
expected = expected =
"<form action='http://www.example.com' id='create-post' method='post'>" + "<form action='http://www.example.com' id='create-post' method='post'>" +
"<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" + "<input name='post[title]' size='30' type='text' id='post_title' value='Hello World' />" +
"<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" + "<textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea>" +
...@@ -601,7 +609,7 @@ def test_form_for_with_labelled_builder ...@@ -601,7 +609,7 @@ def test_form_for_with_labelled_builder
_erbout.concat f.check_box(:secret) _erbout.concat f.check_box(:secret)
end end
expected = expected =
"<form action='http://www.example.com' method='post'>" + "<form action='http://www.example.com' method='post'>" +
"<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" +
"<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" +
...@@ -623,7 +631,7 @@ def test_default_form_builder ...@@ -623,7 +631,7 @@ def test_default_form_builder
_erbout.concat f.check_box(:secret) _erbout.concat f.check_box(:secret)
end end
expected = expected =
"<form action='http://www.example.com' method='post'>" + "<form action='http://www.example.com' method='post'>" +
"<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" +
"<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" +
...@@ -637,39 +645,39 @@ def test_default_form_builder ...@@ -637,39 +645,39 @@ def test_default_form_builder
end end
def test_default_form_builder_with_active_record_helpers def test_default_form_builder_with_active_record_helpers
_erbout = '' _erbout = ''
form_for(:post, @post) do |f| form_for(:post, @post) do |f|
_erbout.concat f.error_message_on('author_name') _erbout.concat f.error_message_on('author_name')
_erbout.concat f.error_messages _erbout.concat f.error_messages
end end
expected = %(<form action='http://www.example.com' method='post'>) + expected = %(<form action='http://www.example.com' method='post'>) +
%(<div class='formError'>can't be empty</div>) + %(<div class='formError'>can't be empty</div>) +
%(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) + %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) +
%(</form>) %(</form>)
assert_dom_equal expected, _erbout assert_dom_equal expected, _erbout
end end
def test_default_form_builder_no_instance_variable def test_default_form_builder_no_instance_variable
post = @post post = @post
@post = nil @post = nil
_erbout = '' _erbout = ''
form_for(:post, post) do |f| form_for(:post, post) do |f|
_erbout.concat f.error_message_on('author_name') _erbout.concat f.error_message_on('author_name')
_erbout.concat f.error_messages _erbout.concat f.error_messages
end end
expected = %(<form action='http://www.example.com' method='post'>) + expected = %(<form action='http://www.example.com' method='post'>) +
%(<div class='formError'>can't be empty</div>) + %(<div class='formError'>can't be empty</div>) +
%(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) + %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) +
%(</form>) %(</form>)
assert_dom_equal expected, _erbout assert_dom_equal expected, _erbout
end end
# Perhaps this test should be moved to prototype helper tests. # Perhaps this test should be moved to prototype helper tests.
...@@ -683,7 +691,7 @@ def test_remote_form_for_with_labelled_builder ...@@ -683,7 +691,7 @@ def test_remote_form_for_with_labelled_builder
_erbout.concat f.check_box(:secret) _erbout.concat f.check_box(:secret)
end end
expected = expected =
%(<form action="http://www.example.com" onsubmit="new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" method="post">) + %(<form action="http://www.example.com" onsubmit="new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;" method="post">) +
"<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" +
"<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" +
...@@ -693,31 +701,31 @@ def test_remote_form_for_with_labelled_builder ...@@ -693,31 +701,31 @@ def test_remote_form_for_with_labelled_builder
assert_dom_equal expected, _erbout assert_dom_equal expected, _erbout
end end
def test_fields_for_with_labelled_builder def test_fields_for_with_labelled_builder
_erbout = '' _erbout = ''
fields_for(:post, @post, :builder => LabelledFormBuilder) do |f| fields_for(:post, @post, :builder => LabelledFormBuilder) do |f|
_erbout.concat f.text_field(:title) _erbout.concat f.text_field(:title)
_erbout.concat f.text_area(:body) _erbout.concat f.text_area(:body)
_erbout.concat f.check_box(:secret) _erbout.concat f.check_box(:secret)
end end
expected = expected =
"<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" + "<label for='title'>Title:</label> <input name='post[title]' size='30' type='text' id='post_title' value='Hello World' /><br/>" +
"<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" + "<label for='body'>Body:</label> <textarea name='post[body]' id='post_body' rows='20' cols='40'>Back to the hill and over it again!</textarea><br/>" +
"<label for='secret'>Secret:</label> <input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" + "<label for='secret'>Secret:</label> <input name='post[secret]' checked='checked' type='checkbox' id='post_secret' value='1' />" +
"<input name='post[secret]' type='hidden' value='0' /><br/>" "<input name='post[secret]' type='hidden' value='0' /><br/>"
assert_dom_equal expected, _erbout assert_dom_equal expected, _erbout
end end
def test_form_for_with_html_options_adds_options_to_form_tag def test_form_for_with_html_options_adds_options_to_form_tag
_erbout = '' _erbout = ''
form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end
expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\"></form>" expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\"></form>"
assert_dom_equal expected, _erbout assert_dom_equal expected, _erbout
end end
...@@ -793,16 +801,16 @@ def test_form_for_with_existing_object_and_namespace_in_list ...@@ -793,16 +801,16 @@ def test_form_for_with_existing_object_and_namespace_in_list
@comment.save @comment.save
_erbout = '' _erbout = ''
form_for([:admin, @post, @comment]) {} form_for([:admin, @post, @comment]) {}
expected = %(<form action="#{admin_comment_path(@post, @comment)}" class="edit_comment" id="edit_comment_1" method="post"><div style="margin:0;padding:0"><input name="_method" type="hidden" value="put" /></div></form>) expected = %(<form action="#{admin_comment_path(@post, @comment)}" class="edit_comment" id="edit_comment_1" method="post"><div style="margin:0;padding:0"><input name="_method" type="hidden" value="put" /></div></form>)
assert_dom_equal expected, _erbout assert_dom_equal expected, _erbout
end end
def test_form_for_with_new_object_and_namespace_in_list def test_form_for_with_new_object_and_namespace_in_list
@post.new_record = false @post.new_record = false
_erbout = '' _erbout = ''
form_for([:admin, @post, @comment]) {} form_for([:admin, @post, @comment]) {}
expected = %(<form action="#{admin_comments_path(@post)}" class="new_comment" id="new_comment" method="post"></form>) expected = %(<form action="#{admin_comments_path(@post)}" class="new_comment" id="new_comment" method="post"></form>)
assert_dom_equal expected, _erbout assert_dom_equal expected, _erbout
end end
...@@ -819,10 +827,10 @@ def test_form_for_with_existing_object_and_custom_url ...@@ -819,10 +827,10 @@ def test_form_for_with_existing_object_and_custom_url
def test_remote_form_for_with_html_options_adds_options_to_form_tag def test_remote_form_for_with_html_options_adds_options_to_form_tag
self.extend ActionView::Helpers::PrototypeHelper self.extend ActionView::Helpers::PrototypeHelper
_erbout = '' _erbout = ''
remote_form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end remote_form_for(:post, @post, :html => {:id => 'some_form', :class => 'some_class'}) do |f| end
expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\" onsubmit=\"new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\"></form>" expected = "<form action=\"http://www.example.com\" class=\"some_class\" id=\"some_form\" method=\"post\" onsubmit=\"new Ajax.Request('http://www.example.com', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\"></form>"
assert_dom_equal expected, _erbout assert_dom_equal expected, _erbout
end end
...@@ -837,21 +845,21 @@ def comment_path(post, comment) ...@@ -837,21 +845,21 @@ def comment_path(post, comment)
"/posts/#{post.id}/comments/#{comment.id}" "/posts/#{post.id}/comments/#{comment.id}"
end end
alias_method :post_comment_path, :comment_path alias_method :post_comment_path, :comment_path
def admin_comments_path(post) def admin_comments_path(post)
"/admin/posts/#{post.id}/comments" "/admin/posts/#{post.id}/comments"
end end
alias_method :admin_post_comments_path, :admin_comments_path alias_method :admin_post_comments_path, :admin_comments_path
def admin_comment_path(post, comment) def admin_comment_path(post, comment)
"/admin/posts/#{post.id}/comments/#{comment.id}" "/admin/posts/#{post.id}/comments/#{comment.id}"
end end
alias_method :admin_post_comment_path, :admin_comment_path alias_method :admin_post_comment_path, :admin_comment_path
def posts_path def posts_path
"/posts" "/posts"
end end
def post_path(post) def post_path(post)
"/posts/#{post.id}" "/posts/#{post.id}"
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册