From 0d1da13914675790daaf8def26f27017bf2d2a44 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 22 Jan 2013 13:07:03 +0100 Subject: render 404 if needed --- core/lib/extensions/couchrest.rb | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'core') diff --git a/core/lib/extensions/couchrest.rb b/core/lib/extensions/couchrest.rb index 5938df4..ca4b608 100644 --- a/core/lib/extensions/couchrest.rb +++ b/core/lib/extensions/couchrest.rb @@ -1,23 +1,32 @@ -module CouchRest::Model::Designs +module CouchRest + module Model::Designs - class View + class View - # so we can called Ticket.method.descending or Ticket.method.ascending - def ascending - self + # so we can called Ticket.method.descending or Ticket.method.ascending + def ascending + self + end end - end - class DesignMapper - def load_views(dir) - Dir.glob("#{dir}/*.js") do |js| - name = File.basename(js, '.js') - file = File.open(js, 'r') - view name.to_sym, - :map => file.read, - :reduce => "function(key, values, rereduce) { return sum(values); }" + class DesignMapper + def load_views(dir) + Dir.glob("#{dir}/*.js") do |js| + name = File.basename(js, '.js') + file = File.open(js, 'r') + view name.to_sym, + :map => file.read, + :reduce => "function(key, values, rereduce) { return sum(values); }" + end end end + end + class ModelRailtie + config.action_dispatch.rescue_responses.merge!( + 'CouchRest::Model::DocumentNotFound' => :not_found, + 'RestClient::ResourceNotFound' => :not_found + ) + end end -- cgit v1.2.3