Permalink
Browse files

Mongomapper ORM now converts DateTime to Time.

  • Loading branch information...
1 parent 680cb0f commit 4c81ecae53ad451171b1ace3dd25249ef74d9465 @josevalim josevalim committed Nov 18, 2009
Showing with 17 additions and 4 deletions.
  1. +5 −0 CHANGELOG.rdoc
  2. +7 −2 lib/devise.rb
  3. +5 −2 lib/devise/orm/mongo_mapper.rb
View
@@ -1,6 +1,11 @@
+* bug fix
+ * MongoMapper now converts DateTime to Time
+
* enhancements
* [#35] Moved friendly_token to Devise
* Added Devise.all, so you can freeze your app strategies
+ * Added Devise.apply_schema, so you can turn it to false in Datamapper or MongoMapper
+ in cases you don't want it be handlded automatically
== 0.5.2
View
@@ -25,7 +25,7 @@ module Devise
:authlogic_sha512 => 128
}
- # Used to encrypt password. Please generate one with rake secret
+ # Used to encrypt password. Please generate one with rake secret.
mattr_accessor :pepper
@@pepper = nil
@@ -64,10 +64,15 @@ def self.encryptor=(value)
mattr_accessor :orm
@@orm = :active_record
- # Configure default options used in :all
+ # Configure default options used in :all.
mattr_accessor :all
@@all = Devise::ALL.dup
+ # Tells if devise should apply the schema in ORMs where devise declaration
+ # and schema belongs to the same class (as Datamapper and MongoMapper).
+ mattr_accessor :apply_schema
+ @@apply_schema = true
+
class << self
# Default way to setup Devise. Run script/generate devise_install to create
# a fresh initializer with all configuration values.
@@ -12,12 +12,15 @@ def self.included_modules_hook(klass, modules)
include Devise::Schema
- # Tell how to apply schema methods.
+ # Tell how to apply schema methods. This automatically converts DateTime
+ # to Time, since MongoMapper does not recognize the former.
def apply_schema(name, type, options={})
+ return unless Devise.apply_schema
+ type = Time if type == DateTime
key name, type, options
end
end
end
end
-MongoMapper::Document::ClassMethods.send(:include, Devise::Models)
+MongoMapper::Document::ClassMethods.send(:include, Devise::Models)

0 comments on commit 4c81eca

Please sign in to comment.