Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Notes

  • Loading branch information...
commit 9636cc00045d246217b3bcebe7ed1df6c16e8b92 1 parent fa17eff
@topfunky authored
View
5 app/controllers/notes_controller.rb
@@ -53,8 +53,9 @@ def destroy
def db
@@couchrest ||= CouchRest.new(COUCHDB_SERVER)
# TODO Run creation tasks, load views, etc.
- @@couchrest.create_db("travel_topfunky") rescue nil
- @db = @@couchrest.database("travel_topfunky")
+ db_name = ["travel", "topfunky", Rails.env].join("_")
+ @@couchrest.create_db(db_name) rescue nil
+ @db = @@couchrest.database(db_name)
end
end
View
2  app/models/basic_model.rb
@@ -53,7 +53,7 @@ def self.init_from_rows(couchdb_results=[])
def update(attributes)
@attributes = @attributes.merge(attributes)
if new_record?
- self.created_at = DateTime.now
+ self.created_at = DateTime.now # "%Y/%m/%d %H:%M:%S %z"
end
self.updated_at = DateTime.now
self.on_update if self.respond_to?(:on_update)
View
19 config/environment.rb
@@ -71,3 +71,22 @@
require 'json/add/core'
require 'json/add/rails'
+
+ENV['TZ'] = 'UTC'
+
+class Time
+ def to_json(*a)
+ {
+ 'json_class' => self.class.name,
+ 'data' => self.strftime("%Y/%m/%d %H:%M:%S %z")
+ }.to_json(*a)
+ end
+end
+
+class Time
+ def self.json_create(o)
+ parse(*o['data'])
+ end
+end
+
+# catch RestClient::RequestFailed 412 conflict
Please sign in to comment.
Something went wrong with that request. Please try again.