Permalink
Browse files

Updated for current CouchRest syntax

Fixed couchdb view function
  • Loading branch information...
1 parent 389a8d4 commit 9443f9a87bf6fc75c6c71237bc293e298e1ea2d7 @topfunky committed Sep 12, 2008
Showing with 12 additions and 11 deletions.
  1. +1 −1 app/controllers/application.rb
  2. +6 −9 app/models/basic_model.rb
  3. +5 −1 couchdb_views/notes/by_visited_on-map.js
@@ -16,7 +16,7 @@ class ApplicationController < ActionController::Base
protected
def database_name
- ["script", "topfunky", Rails.env].join("_")
+ COUCHDB_SERVER + "/" + ["demo", "topfunky", Rails.env].join("_")
end
end
View
@@ -19,15 +19,12 @@ class BasicModel
def self.db(database_name)
puts "Getting #{database_name}"
- @@couchrest = CouchRest.new(COUCHDB_SERVER)
- begin
- @@couchrest.create_db(database_name)
- file_manager = CouchRest::FileManager.new(database_name)
- file_manager.push_views(File.join(Rails.root, "couchdb_views"))
- rescue
- nil
- end
- @@couchrest.database(database_name)
+ database = CouchRest.database!(database_name)
+ # Load views
+ file_manager = CouchRest::FileManager.new(File.basename(database_name))
+ file_manager.push_views(File.join(Rails.root, "couchdb_views"))
+
+ database
end
##
@@ -1,5 +1,9 @@
function(doc) {
if (doc.type == "Note" && doc.visited_on) {
- emit(doc.visited_on, doc);
+ date_array = doc.visited_on.split("/");
+ date_array = date_array.map(function(d) {
+ return parseInt(d, 10);
+ });
+ emit(date_array, doc);
}
}

0 comments on commit 9443f9a

Please sign in to comment.