fixed a bug with ExtendedDocument not declaring any views and trying to use #all or #first

This commit is contained in:
Matt Aimonetti 2009-03-03 16:57:59 -08:00
parent 98fb1d728d
commit 3e6dba7b66
2 changed files with 3 additions and 3 deletions

View file

@ -16,6 +16,7 @@ module CouchRest
def design_doc_slug
return design_doc_slug_cache if (design_doc_slug_cache && design_doc_fresh)
funcs = []
design_doc ||= Design.new(default_design_doc)
design_doc['views'].each do |name, view|
funcs << "#{name}/#{view['map']}#{view['reduce']}"
end

View file

@ -129,12 +129,11 @@ module CouchRest
private
def fetch_view_with_docs(name, opts, raw=false, &block)
if raw
if raw || (opts.has_key?(:include_docs) && opts[:include_docs] == false)
fetch_view(name, opts, &block)
else
begin
# auto load mentioned documents unless asked differently (didn't use merge! on a previous line to avoid duping the object)
view = fetch_view name, (opts.has_key?(:include_docs) ? opts : opts.merge({:include_docs => true})), &block
view = fetch_view name, opts.merge({:include_docs => true}), &block
view['rows'].collect{|r|new(r['doc'])} if view['rows']
rescue
# fallback for old versions of couchdb that don't