Fixing big problem with lack of database passed to collection proxy

This commit is contained in:
Sam Lown 2010-06-25 20:02:18 +02:00
parent c52f009270
commit efb07295f0

View file

@ -127,18 +127,11 @@ module CouchRest
if raw || (opts.has_key?(:include_docs) && opts[:include_docs] == false)
fetch_view(db, name, opts, &block)
else
begin
if block.nil?
collection_proxy_for(design_doc, name, opts.merge({:include_docs => true}))
else
view = fetch_view db, name, opts.merge({:include_docs => true}), &block
view['rows'].collect{|r|create_from_database(r['doc'])} if view['rows']
end
rescue
# fallback for old versions of couchdb that don't
# have include_docs support
view = fetch_view(db, name, opts, &block)
view['rows'].collect{|r|create_from_database(db.get(r['id']))} if view['rows']
if block.nil?
collection_proxy_for(design_doc, name, opts.merge({:database => db, :include_docs => true}))
else
view = fetch_view db, name, opts.merge({:include_docs => true}), &block
view['rows'].collect{|r|create_from_database(r['doc'])} if view['rows']
end
end
end