diff --git a/lib/generators/active_record/devise_generator.rb b/lib/generators/active_record/devise_generator.rb index 1ae52c37..b7633500 100644 --- a/lib/generators/active_record/devise_generator.rb +++ b/lib/generators/active_record/devise_generator.rb @@ -20,7 +20,7 @@ module ActiveRecord def generate_model invoke "active_record:model", [name], :migration => false unless model_exists? && behavior == :invoke end - + def inject_devise_content inject_into_class(model_path, class_name, model_contents + < 0 t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip diff --git a/lib/generators/mongoid/devise_generator.rb b/lib/generators/mongoid/devise_generator.rb index d6b49875..db726e2c 100644 --- a/lib/generators/mongoid/devise_generator.rb +++ b/lib/generators/mongoid/devise_generator.rb @@ -9,9 +9,52 @@ module Mongoid invoke "mongoid:model", [name] unless model_exists? && behavior == :invoke end + def inject_field_types + inject_into_file model_path, migration_data, :after => "include Mongoid::Document\n" if model_exists? + end + def inject_devise_content inject_into_file model_path, model_contents, :after => "include Mongoid::Document\n" if model_exists? end + + def migration_data +< String, :null => false + field :encrypted_password, :type => String, :null => false + + ## Recoverable + field :reset_password_token, :type => String + field :reset_password_sent_at, :type => Time + + ## Rememberable + field :remember_created_at, :type => Time + + ## Trackable + field :sign_in_count, :type => Integer + field :current_sign_in_at, :type => Time + field :last_sign_in_at, :type => Time + field :current_sign_in_ip, :type => String + field :last_sign_in_ip, :type => String + + ## Encryptable + # field :password_salt, :type => String + + ## Confirmable + # field :confirmation_token, :type => String + # field :confirmed_at, :type => Time + # field :confirmation_sent_at, :type => Time + # field :unconfirmed_email, :type => String # Only if using reconfirmable + + ## Lockable + # field :failed_attempts, :type => Integer # Only if lock strategy is :failed_attempts + # field :unlock_token, :type => String # Only if unlock strategy is :email or :both + # field :locked_at, :type => Time + + # Token authenticatable + # field :authentication_token, :type => String +RUBY + end end end end \ No newline at end of file diff --git a/test/rails_app/config/initializers/devise.rb b/test/rails_app/config/initializers/devise.rb index b09d2dfd..0ae9b35d 100644 --- a/test/rails_app/config/initializers/devise.rb +++ b/test/rails_app/config/initializers/devise.rb @@ -12,6 +12,9 @@ Devise.setup do |config| # Configure the class responsible to send e-mails. # config.mailer = "Devise::Mailer" + # Disable apply schema + config.apply_schema = false + # ==> ORM configuration # Load and configure the ORM. Supports :active_record (default) and # :mongoid (bson_ext recommended) by default. Other ORMs may be