From 44542bd7daf03057fe502f21f3eb2a5c09ffea57 Mon Sep 17 00:00:00 2001 From: "Erik St. Martin" Date: Mon, 25 Jan 2010 19:48:39 -0500 Subject: account for the fact a few options may be passed as symbols and need to be converted to string --- actionpack/lib/action_view/helpers/ajax_helper.rb | 16 ++++++++++++---- actionpack/test/template/ajax_helper_test.rb | 5 +++++ 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/ajax_helper.rb b/actionpack/lib/action_view/helpers/ajax_helper.rb index adb686aad4..52b7db4de9 100644 --- a/actionpack/lib/action_view/helpers/ajax_helper.rb +++ b/actionpack/lib/action_view/helpers/ajax_helper.rb @@ -291,7 +291,7 @@ module ActionView # :href => url_for(:action => "destroy", :id => post.id) def link_to_remote(name, options, html_options = {}) attributes = {} - attributes.merge!(:rel => "nofollow") if options[:method] && options[:method].downcase == "delete" + attributes.merge!(:rel => "nofollow") if options[:method] && options[:method].to_s.downcase == "delete" attributes.merge!(extract_remote_attributes!(options)) if confirm = options.delete(:confirm) @@ -512,8 +512,13 @@ module ActionView def extract_request_attributes!(options) attributes = {} - attributes["data-method"] = options.delete(:method) - attributes["data-remote-type"] = options.delete(:type) + if method = options.delete(:method) + attributes["data-method"] = method.to_s + end + + if type = options.delete(:type) + attributes["data-remote-type"] = type.to_s + end url_options = options.delete(:url) url_options = url_options.merge(:escape => false) if url_options.is_a?(Hash) @@ -531,7 +536,10 @@ module ActionView else attributes["data-update-success"] = update end - attributes["data-update-position"] = options.delete(:position) + + if position = options.delete(:position) + attributes["data-update-position"] = position.to_s + end purge_unused_attributes!(attributes) end diff --git a/actionpack/test/template/ajax_helper_test.rb b/actionpack/test/template/ajax_helper_test.rb index c688b25f70..2e46a38656 100644 --- a/actionpack/test/template/ajax_helper_test.rb +++ b/actionpack/test/template/ajax_helper_test.rb @@ -111,6 +111,11 @@ class AjaxHelperTest < AjaxHelperBaseTest link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :method => "delete"}, { :class => "fine" }) end + test "link_to_remote with method delete as symbol" do + assert_dom_equal %(Remote outauthor), + link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :method => :delete}, { :class => "fine" }) + end + test "link_to_remote html options" do assert_dom_equal %(Remote outauthor), link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :html => { :class => "fine" } }) -- cgit v1.2.3