aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource/base.rb
diff options
context:
space:
mode:
authorGonçalo Silva <goncalossilva@gmail.com>2010-08-10 18:15:12 +0100
committerGonçalo Silva <goncalossilva@gmail.com>2010-08-10 18:15:12 +0100
commit62658500049fbb7a5e7d75537dd6f6a374204207 (patch)
tree8892d8305ced43866068a6c1c66548e465e45b38 /activeresource/lib/active_resource/base.rb
parentcd2bbed9846d84a1230a1b9e52843eedca17b28d (diff)
parente86cced311539932420f9cda49d736606d106c28 (diff)
downloadrails-62658500049fbb7a5e7d75537dd6f6a374204207.tar.gz
rails-62658500049fbb7a5e7d75537dd6f6a374204207.tar.bz2
rails-62658500049fbb7a5e7d75537dd6f6a374204207.zip
Merge branch 'master' of http://github.com/rails/rails
Diffstat (limited to 'activeresource/lib/active_resource/base.rb')
-rw-r--r--activeresource/lib/active_resource/base.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 6c494a8bcc..62420725ad 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -7,7 +7,6 @@ require 'active_support/core_ext/module/attr_accessor_with_default'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/module/aliasing'
require 'active_support/core_ext/object/blank'
-require 'active_support/core_ext/object/misc'
require 'active_support/core_ext/object/to_query'
require 'active_support/core_ext/object/duplicable'
require 'set'
@@ -578,7 +577,7 @@ module ActiveResource
# Default value is <tt>site.path</tt>.
def prefix=(value = '/')
# Replace :placeholders with '#{embedded options[:lookups]}'
- prefix_call = value.gsub(/:\w+/) { |key| "\#{options[#{key}]}" }
+ prefix_call = value.gsub(/:\w+/) { |key| "\#{URI.escape options[#{key}].to_s}" }
# Clear prefix parameters in case they have been cached
@prefix_parameters = nil
@@ -623,7 +622,7 @@ module ActiveResource
#
def element_path(id, prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
- "#{prefix(prefix_options)}#{collection_name}/#{id}.#{format.extension}#{query_string(query_options)}"
+ "#{prefix(prefix_options)}#{collection_name}/#{URI.escape id.to_s}.#{format.extension}#{query_string(query_options)}"
end
# Gets the new element path for REST resources.
@@ -1223,10 +1222,10 @@ module ActiveResource
when Array
resource = find_or_create_resource_for_collection(key)
value.map do |attrs|
- if attrs.is_a?(String) || attrs.is_a?(Numeric)
- attrs.duplicable? ? attrs.dup : attrs
- else
+ if attrs.is_a?(Hash)
resource.new(attrs)
+ else
+ attrs.duplicable? ? attrs.dup : attrs
end
end
when Hash