diff --git a/lib/draper/railtie.rb b/lib/draper/railtie.rb index 69c700a..128f446 100755 --- a/lib/draper/railtie.rb +++ b/lib/draper/railtie.rb @@ -6,7 +6,7 @@ module ActiveModel app ||= Rails.application # Rails 3.0.x does not yield `app` Rails::Generators.configure! app.config.generators - require_relative '../generators/resource_override' + require_relative '../generators/controller_override' end end end diff --git a/lib/generators/controller_override.rb b/lib/generators/controller_override.rb new file mode 100644 index 0000000..ba659bc --- /dev/null +++ b/lib/generators/controller_override.rb @@ -0,0 +1,17 @@ +require "rails/generators" +require "rails/generators/rails/controller/controller_generator" +require "rails/generators/rails/scaffold_controller/scaffold_controller_generator" + +module Rails + module Generators + + class ControllerGenerator + hook_for :decorator, default: true + end + + class ScaffoldControllerGenerator + hook_for :decorator, default: true + end + + end +end diff --git a/lib/generators/decorator/decorator_generator.rb b/lib/generators/rails/decorator_generator.rb similarity index 100% rename from lib/generators/decorator/decorator_generator.rb rename to lib/generators/rails/decorator_generator.rb diff --git a/lib/generators/decorator/templates/decorator.rb b/lib/generators/rails/templates/decorator.rb similarity index 100% rename from lib/generators/decorator/templates/decorator.rb rename to lib/generators/rails/templates/decorator.rb diff --git a/lib/generators/resource_override.rb b/lib/generators/resource_override.rb deleted file mode 100644 index 40a85ce..0000000 --- a/lib/generators/resource_override.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "rails/generators" -require "rails/generators/rails/resource/resource_generator" - -module Rails - module Generators - ResourceGenerator.class_eval do - def add_decorator - invoke "decorator" - end - end - end -end diff --git a/spec/generators/decorator/decorator_generator_spec.rb b/spec/generators/decorator/decorator_generator_spec.rb index 2218cb2..f7ab75f 100644 --- a/spec/generators/decorator/decorator_generator_spec.rb +++ b/spec/generators/decorator/decorator_generator_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'rails' require 'ammeter/init' -require 'generators/decorator/decorator_generator' +require 'generators/rails/decorator_generator' describe Rails::Generators::DecoratorGenerator do destination File.expand_path("../tmp", __FILE__)