From c7fd6db443ba0633a3e24ca560e1606d3a0aa3a3 Mon Sep 17 00:00:00 2001 From: Nicolas Sanguinetti Date: Sat, 20 Mar 2010 17:46:06 -0300 Subject: [PATCH] Allow passing :remote => false to links Allows conditionally disabling the UJS behavior by passing :remote => false, which in turn doesn't emit a data-remote attribute --- actionpack/lib/action_view/helpers/url_helper.rb | 4 +--- actionpack/test/template/url_helper_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 79232e2..576d6b3 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -569,10 +569,8 @@ module ActionView html_options = {} if html_options.nil? html_options = html_options.stringify_keys - if (options.is_a?(Hash) && options.key?('remote')) || (html_options.is_a?(Hash) && html_options.key?('remote')) + if (options.is_a?(Hash) && options.key?('remote') && options.delete('remote')) || (html_options.is_a?(Hash) && html_options.key?('remote') && html_options.delete('remote')) html_options['data-remote'] = 'true' - options.delete('remote') if options.is_a?(Hash) - html_options.delete('remote') if html_options.is_a?(Hash) end confirm = html_options.delete("confirm") diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 87b2e59..531be12 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -201,6 +201,13 @@ class UrlHelperTest < ActionView::TestCase ) end + def test_link_to_with_remote_false + assert_dom_equal( + "Hello", + link_to("Hello", "http://www.example.com", :remote => false) + ) + end + def test_link_tag_using_post_javascript assert_dom_equal( "Hello", -- 1.6.5.2