From c0b05bf44941a2fd7e2ce1ef0509beeee466371a Mon Sep 17 00:00:00 2001 From: Jeff Casimir Date: Fri, 29 Jul 2011 20:33:39 -0500 Subject: [PATCH] Don't attempt to overwrite an existing ApplicationDecorator --- lib/generators/draper/model/model_generator.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/generators/draper/model/model_generator.rb b/lib/generators/draper/model/model_generator.rb index 751ffdb..6994be2 100644 --- a/lib/generators/draper/model/model_generator.rb +++ b/lib/generators/draper/model/model_generator.rb @@ -2,10 +2,16 @@ module Draper class ModelGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) + DECORATORS_ROOT = 'app/decorators/' + APPLICATION_DECORATOR = 'application_decorator.rb' + APPLICATION_DECORATOR_PATH = DECORATORS_ROOT + APPLICATION_DECORATOR + def build_model_and_application_decorators empty_directory "app/decorators" - template 'application_decorator.rb', 'app/decorators/application_decorator.rb' - template 'model.rb', "app/decorators/#{singular_name}_decorator.rb" + unless File.exists?(APPLICATION_DECORATOR_PATH) + template APPLICATION_DECORATOR, APPLICATION_DECORATOR_PATH + end + template 'model.rb', "#{DECORATORS_ROOT}#{singular_name}_decorator.rb" end end end \ No newline at end of file