diff options
Diffstat (limited to 'railties/lib/generators')
3 files changed, 16 insertions, 2 deletions
diff --git a/railties/lib/generators/erb/scaffold/scaffold_generator.rb b/railties/lib/generators/erb/scaffold/scaffold_generator.rb index 618742dde6..1841124ae4 100644 --- a/railties/lib/generators/erb/scaffold/scaffold_generator.rb +++ b/railties/lib/generators/erb/scaffold/scaffold_generator.rb @@ -10,6 +10,10 @@ module Erb class_option :singleton, :type => :boolean, :desc => "Supply to skip index action" class_option :layout, :type => :boolean + def create_root_folder + empty_directory File.join("app/views", controller_file_path) + end + def copy_index_file return if options[:singleton] copy_view :index diff --git a/railties/lib/generators/rails/plugin/plugin_generator.rb b/railties/lib/generators/rails/plugin/plugin_generator.rb index c2583ee147..ec563be805 100644 --- a/railties/lib/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/generators/rails/plugin/plugin_generator.rb @@ -11,7 +11,7 @@ module Rails def create_root self.root = File.expand_path("vendor/plugins/#{file_name}", root) - empty_directory '.' + empty_directory '.' if behavior == :invoke FileUtils.cd(root) end @@ -36,6 +36,16 @@ module Rails return unless options[:with_generator] directory 'generators' end + + # Work around for generator to work on revoke. If we remove the root + # folder at the beginning, it will raise an error since FileUtils.cd + # will move to a non-existent folder. + # + def remove_on_revoke + return unless behavior == :revoke + FileUtils.cd("../../..") + empty_directory "vendor/plugins/#{file_name}" + end end end end diff --git a/railties/lib/generators/rails/stylesheets/stylesheets_generator.rb b/railties/lib/generators/rails/stylesheets/stylesheets_generator.rb index 256b9a208f..ce68443c39 100644 --- a/railties/lib/generators/rails/stylesheets/stylesheets_generator.rb +++ b/railties/lib/generators/rails/stylesheets/stylesheets_generator.rb @@ -2,7 +2,7 @@ module Rails module Generators class StylesheetsGenerator < Base def copy_stylesheets_file - copy_file "scaffold.css", "public/stylesheets/scaffold.css" + template "scaffold.css", "public/stylesheets/scaffold.css" if behavior == :invoke end end end |