From 68420e4bd1e5bedaa6837b02926e0d22d2e074e4 Mon Sep 17 00:00:00 2001 From: Steve Shreeve Date: Mon, 1 Mar 2010 23:20:34 -0500 Subject: [PATCH] lazily create resources so that fields beginning with an underscore are not constantized (since that will fail) --- activeresource/lib/active_resource/base.rb | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index b841108..0ded0c2 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -1242,11 +1242,12 @@ module ActiveResource @attributes[key.to_s] = case value when Array - resource = find_or_create_resource_for_collection(key) + resource = nil value.map do |attrs| if attrs.is_a?(String) || attrs.is_a?(Numeric) attrs.duplicable? ? attrs.dup : attrs else + resource ||= find_or_create_resource_for_collection(key) resource.new(attrs) end end -- 1.6.0.4