From efb07295f0e71c7783c830c5820c30de26442ada Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Fri, 25 Jun 2010 20:02:18 +0200 Subject: [PATCH] Fixing big problem with lack of database passed to collection proxy --- lib/couchrest/model/views.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/couchrest/model/views.rb b/lib/couchrest/model/views.rb index bd5c0bc..68e55bd 100644 --- a/lib/couchrest/model/views.rb +++ b/lib/couchrest/model/views.rb @@ -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