Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1796 from jdeseno/master

link_to doesn't allow rel attribute when also specifying method
  • Loading branch information...
commit 816f0b691d2e7d902ae69f49b68f890eae85eeca 1 parent 8e6f86e
@spastorino spastorino authored
View
4 actionpack/lib/action_view/helpers/url_helper.rb
@@ -629,7 +629,9 @@ def link_to_remote_options?(options)
end
def add_method_to_attributes!(html_options, method)
- html_options["rel"] = "nofollow" if method.to_s.downcase != "get"
+ if method && method.to_s.downcase != "get"
+ html_options["rel"] = "#{html_options["rel"].to_s} nofollow".split(" ").uniq.join(" ")
+ end
html_options["data-method"] = method
end
View
7 actionpack/test/template/url_helper_test.rb
@@ -247,6 +247,13 @@ def test_link_tag_using_delete_javascript_and_href
)
end
+ def test_link_tag_using_post_javascript_and_rel
+ assert_dom_equal(
+ "<a href='http://www.example.com' data-method=\"post\" rel=\"example nofollow\">Hello</a>",
+ link_to("Hello", "http://www.example.com", :method => :post, :rel => 'example')
+ )
+ end
+
def test_link_tag_using_post_javascript_and_confirm
assert_dom_equal(
"<a href=\"http://www.example.com\" data-method=\"post\" rel=\"nofollow\" data-confirm=\"Are you serious?\">Hello</a>",
Please sign in to comment.
Something went wrong with that request. Please try again.