提交 4b4db54e 编写于 作者: A Attila Domokos

Adding an documentation example and a test to button_to with path

I did not see in the docs that `button_to` supports not only URLs but paths as well. I documented this functionality with a unit tests and added an example to the docs as well.
上级 4ac11447
......@@ -232,6 +232,11 @@ def link_to(name = nil, options = nil, html_options = nil, &block)
# # <div><input value="New" type="submit" /></div>
# # </form>"
#
# <%= button_to "New", new_articles_path %>
# # => "<form method="post" action="/articles/new" class="button_to">
# # <div><input value="New" type="submit" /></div>
# # </form>"
#
# <%= button_to [:make_happy, @user] do %>
# Make happy <strong><%= @user.name %></strong>
# <% end %>
......
......@@ -56,6 +56,13 @@ def test_button_to_with_straight_url
assert_dom_equal %{<form method="post" action="http://www.example.com" class="button_to"><div><input type="submit" value="Hello" /></div></form>}, button_to("Hello", "http://www.example.com")
end
def test_button_to_with_path
assert_dom_equal(
%{<form method="post" action="/article/Hello" class="button_to"><div><input type="submit" value="Hello" /></div></form>},
button_to("Hello", article_path("Hello".html_safe))
)
end
def test_button_to_with_straight_url_and_request_forgery
self.request_forgery = true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册