Skip to content

Commit

Permalink
Fixing big problem with lack of database passed to collection proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Jun 25, 2010
1 parent c52f009 commit efb0729
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions lib/couchrest/model/views.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,11 @@ def fetch_view_with_docs(db, name, opts, raw=false, &block)
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
Expand Down

0 comments on commit efb0729

Please sign in to comment.