Skip to content
This repository
Browse code

Accept :remote as symbol in link_to options

Accept either :remote or 'remote' in both the html_options and
(url_)options hash arguments to link_to.
  • Loading branch information...
commit 380800e4a272db98f3dd267f82e0ce1e4d03f4b8 1 parent 92d7612
Riley Martinez-Lynch authored October 06, 2012 teleological committed October 06, 2012
2  actionpack/CHANGELOG.md
Source Rendered
... ...
@@ -1,5 +1,7 @@
1 1
 ## Rails 3.2.9 (unreleased) ##
2 2
 
  3
+*   Accept :remote as symbolic option for `link_to` helper. *Riley Lynch*
  4
+
3 5
 *   Warn when the `:locals` option is passed to `assert_template` outside of a view test case
4 6
     Fix #3415
5 7
 
4  actionpack/lib/action_view/helpers/url_helper.rb
@@ -633,7 +633,9 @@ def convert_options_to_data_attributes(options, html_options)
633 633
         end
634 634
 
635 635
         def link_to_remote_options?(options)
636  
-          options.is_a?(Hash) && options.key?('remote') && options.delete('remote')
  636
+          if options.is_a?(Hash)
  637
+            options.delete('remote') || options.delete(:remote)
  638
+          end
637 639
         end
638 640
 
639 641
         def add_method_to_attributes!(html_options, method)
7  actionpack/test/template/url_helper_test.rb
@@ -227,6 +227,13 @@ def test_link_to_with_remote_false
227 227
     )
228 228
   end
229 229
 
  230
+  def test_link_to_with_symbolic_remote_in_non_html_options
  231
+    assert_dom_equal(
  232
+      "<a href=\"/\" data-remote=\"true\">Hello</a>",
  233
+      link_to("Hello", hash_for([:remote, true]), {})
  234
+    )
  235
+  end
  236
+
230 237
   def test_link_tag_using_post_javascript
231 238
     assert_dom_equal(
232 239
       "<a href='http://www.example.com' data-method=\"post\" rel=\"nofollow\">Hello</a>",

0 notes on commit 380800e

Please sign in to comment.
Something went wrong with that request. Please try again.