diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-06 17:13:17 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-06 17:13:17 -0700 |
commit | bf07c79a02d7498c9025d97b1302a80d21066ba5 (patch) | |
tree | 7b2dd5e81001a6046343b01af4f963118eca4c87 | |
parent | f668ab9adf85d3662067a8216c5b52b934c2167f (diff) | |
parent | 380800e4a272db98f3dd267f82e0ce1e4d03f4b8 (diff) | |
download | rails-bf07c79a02d7498c9025d97b1302a80d21066ba5.tar.gz rails-bf07c79a02d7498c9025d97b1302a80d21066ba5.tar.bz2 rails-bf07c79a02d7498c9025d97b1302a80d21066ba5.zip |
Merge pull request #7865 from teleological/link_to_remote_3_2
Accept :remote as symbol in link_to options (backport)
-rw-r--r-- | actionpack/CHANGELOG.md | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/url_helper.rb | 4 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 7 |
3 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index ebd92ed0c9..1d38e33874 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,5 +1,7 @@ ## Rails 3.2.9 (unreleased) ## +* Accept :remote as symbolic option for `link_to` helper. *Riley Lynch* + * Warn when the `:locals` option is passed to `assert_template` outside of a view test case Fix #3415 diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 1f1cd3cee3..812bb4de9e 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -633,7 +633,9 @@ module ActionView end def link_to_remote_options?(options) - options.is_a?(Hash) && options.key?('remote') && options.delete('remote') + if options.is_a?(Hash) + options.delete('remote') || options.delete(:remote) + end end def add_method_to_attributes!(html_options, method) diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index d55b1fd2bd..38f77203e0 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -227,6 +227,13 @@ class UrlHelperTest < ActiveSupport::TestCase ) end + def test_link_to_with_symbolic_remote_in_non_html_options + assert_dom_equal( + "<a href=\"/\" data-remote=\"true\">Hello</a>", + link_to("Hello", hash_for([:remote, true]), {}) + ) + end + def test_link_tag_using_post_javascript assert_dom_equal( "<a href='http://www.example.com' data-method=\"post\" rel=\"nofollow\">Hello</a>", |