Permalink
Browse files

Merge pull request #15091 from printercu/patch-5

Do not check defined?(CGI) on every call #to_query
  • Loading branch information...
2 parents c4c5801 + f179895 commit 977d36af8f84f467b6e4d21115cd4f84e50cfcb3 @pixeltrix pixeltrix committed May 13, 2014
Showing with 1 addition and 1 deletion.
  1. +1 −1 activesupport/lib/active_support/core_ext/object/to_query.rb
@@ -1,12 +1,12 @@
require 'active_support/core_ext/object/to_param'
+require 'cgi'
class Object
# Converts an object into a string suitable for use as a URL query string, using the given <tt>key</tt> as the
# param name.
#
# Note: This method is defined as a default implementation for all Objects for Hash#to_query to work.
def to_query(key)
- require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
"#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}"
end
end

0 comments on commit 977d36a

Please sign in to comment.