1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Invoking the model generator even if the model exists but only when the behavior is :revoke (i.e. we are running 'rails destroy' instead of 'rails generate')

This commit is contained in:
Andrés Mejía 2010-12-10 06:15:55 +08:00 committed by José Valim
parent 845c186f48
commit fe4eaf2d12
2 changed files with 4 additions and 4 deletions

View file

@ -10,7 +10,7 @@ module ActiveRecord
source_root File.expand_path("../templates", __FILE__)
def generate_model
invoke "active_record:model", [name], :migration => false unless model_exists?
invoke "active_record:model", [name], :migration => false unless model_exists? && behavior == :invoke
end
def copy_devise_migration
@ -18,7 +18,7 @@ module ActiveRecord
end
def inject_devise_content
inject_into_class model_path, class_name, model_contents + <<-CONTENT
inject_into_class(model_path, class_name, model_contents + <<CONTENT) if model_exists?
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
CONTENT

View file

@ -6,11 +6,11 @@ module Mongoid
include Devise::Generators::OrmHelpers
def generate_model
invoke "mongoid:model", [name] unless model_exists?
invoke "mongoid:model", [name] unless model_exists? && behavior == :invoke
end
def inject_devise_content
inject_into_file model_path, model_contents, :after => "include Mongoid::Document\n"
inject_into_file model_path, model_contents, :after => "include Mongoid::Document\n" if model_exists?
end
end
end