Skip to content

Commit 2edf657

Browse files
authored
Merge pull request rails#53049 from fatkodima/fix-link_to-with-symbol-rel
Fix `link_to` when passed `:rel` is a symbol
2 parents b54833f + 99fd2f4 commit 2edf657

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

actionview/lib/action_view/helpers/url_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ def link_to_remote_options?(options)
710710
end
711711

712712
def add_method_to_attributes!(html_options, method)
713-
if method_not_get_method?(method) && !html_options["rel"]&.include?("nofollow")
713+
if method_not_get_method?(method) && !html_options["rel"].to_s.include?("nofollow")
714714
if html_options["rel"].blank?
715715
html_options["rel"] = "nofollow"
716716
else

actionview/test/template/url_helper_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,11 @@ def test_link_tag_using_post_javascript_and_rel
579579
%{<a href="http://www.example.com" data-method="post" rel="example nofollow">Hello</a>},
580580
link_to("Hello", "http://www.example.com", method: :post, rel: "example")
581581
)
582+
583+
assert_dom_equal(
584+
%{<a href="http://www.example.com" data-method="post" rel="example nofollow">Hello</a>},
585+
link_to("Hello", "http://www.example.com", method: :post, rel: :example)
586+
)
582587
end
583588

584589
def test_link_tag_using_post_javascript_and_confirm

0 commit comments

Comments
 (0)