rvanmelle
2006-Nov-11 18:41 UTC
problem with the find_every routine in ActiveResource base.rb
I''ve been getting errors with the find_every routine whenever I try to
get a list of items when there are either only zero or one item.
Since I''m a bit of a nube, I assume that this is an error in the our
server code. However, I also found that everything worked much better
when I patched the routine with the following code. It seemed to
handle all of the cases with grace and ease.
Is this likely a stupid error in the server rendering? or is this a
valid patch?
private
# { :people => { :person => [ person1, person2 ] } }
def find_every(options)
data = connection.get(collection_path(options))
if data.values.first.nil?
[]
else
if data.values.first.values.first.class == Array
data.values.first.values.first.collect { |element|
new(element, options) }
else # It is a HASH
data.values.first.values.collect { |element| new(element,
options) }
end
end
end
- Reid
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---