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

@@ -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