diff options
Diffstat (limited to 'railties/lib/generators/rails')
8 files changed, 40 insertions, 5 deletions
diff --git a/railties/lib/generators/rails/migration/migration_generator.rb b/railties/lib/generators/rails/migration/migration_generator.rb index cfaa5f0ad2..29d1238072 100644 --- a/railties/lib/generators/rails/migration/migration_generator.rb +++ b/railties/lib/generators/rails/migration/migration_generator.rb @@ -1,6 +1,6 @@ module Rails module Generators - class MigrationGenerator < NamedBase + class MigrationGenerator < NamedBase #metagenerator argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type" hook_for :orm end diff --git a/railties/lib/generators/rails/model/model_generator.rb b/railties/lib/generators/rails/model/model_generator.rb index e05c89517e..2e13f6f3cb 100644 --- a/railties/lib/generators/rails/model/model_generator.rb +++ b/railties/lib/generators/rails/model/model_generator.rb @@ -1,6 +1,6 @@ module Rails module Generators - class ModelGenerator < NamedBase + class ModelGenerator < NamedBase #metagenerator argument :attributes, :type => :hash, :default => {}, :banner => "field:type field:type" hook_for :orm end diff --git a/railties/lib/generators/rails/observer/observer_generator.rb b/railties/lib/generators/rails/observer/observer_generator.rb index 1d99f309e0..9332c3542a 100644 --- a/railties/lib/generators/rails/observer/observer_generator.rb +++ b/railties/lib/generators/rails/observer/observer_generator.rb @@ -1,6 +1,6 @@ module Rails module Generators - class ObserverGenerator < NamedBase + class ObserverGenerator < NamedBase #metagenerator hook_for :orm end end diff --git a/railties/lib/generators/rails/scaffold/scaffold_generator.rb b/railties/lib/generators/rails/scaffold/scaffold_generator.rb index 1386000d9b..73ec294cf0 100644 --- a/railties/lib/generators/rails/scaffold/scaffold_generator.rb +++ b/railties/lib/generators/rails/scaffold/scaffold_generator.rb @@ -2,8 +2,9 @@ require 'generators/rails/resource/resource_generator' module Rails module Generators - class ScaffoldGenerator < ResourceGenerator + class ScaffoldGenerator < ResourceGenerator #metagenerator remove_hook_for :actions, :resource_controller + hook_for :scaffold_controller end end end diff --git a/railties/lib/generators/rails/scaffold_controller/USAGE b/railties/lib/generators/rails/scaffold_controller/USAGE new file mode 100644 index 0000000000..2570da2e85 --- /dev/null +++ b/railties/lib/generators/rails/scaffold_controller/USAGE @@ -0,0 +1,18 @@ +Description: + Stubs out a scaffolded controller and its views. Pass the controller name, + either CamelCased or under_scored, and a list of views as arguments. + + To create a controller within a module, specify the controller name as a + path like 'parent_module/controller_name'. + + This generates a controller class in app/controllers and invokes helper, + template engine and test framework generators. + +Example: + `./script/generate scaffold_controller CreditCard open debit credit close` + + Credit card controller with URLs like /credit_card/debit. + Controller: app/controllers/credit_card_controller.rb + Functional Test: test/functional/credit_card_controller_test.rb + Views: app/views/credit_card/debit.html.erb [...] + Helper: app/helpers/credit_card_helper.rb diff --git a/railties/lib/generators/rails/scaffold_controller/scaffold_controller_generator.rb b/railties/lib/generators/rails/scaffold_controller/scaffold_controller_generator.rb new file mode 100644 index 0000000000..4d36b6603b --- /dev/null +++ b/railties/lib/generators/rails/scaffold_controller/scaffold_controller_generator.rb @@ -0,0 +1,14 @@ +module Rails + module Generators + class ScaffoldControllerGenerator < NamedBase + check_class_collision :suffix => "Controller" + + def create_controller_files + template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb") + end + + hook_for :template_engine, :test_framework, :as => :scaffold + invoke_if :helper + end + end +end diff --git a/railties/lib/generators/rails/scaffold_controller/templates/controller.rb b/railties/lib/generators/rails/scaffold_controller/templates/controller.rb new file mode 100644 index 0000000000..6bf38cb9b4 --- /dev/null +++ b/railties/lib/generators/rails/scaffold_controller/templates/controller.rb @@ -0,0 +1,2 @@ +class <%= class_name %>Controller < ApplicationController +end diff --git a/railties/lib/generators/rails/session_migration/session_migration_generator.rb b/railties/lib/generators/rails/session_migration/session_migration_generator.rb index e7d988359c..5812c40e55 100644 --- a/railties/lib/generators/rails/session_migration/session_migration_generator.rb +++ b/railties/lib/generators/rails/session_migration/session_migration_generator.rb @@ -1,6 +1,6 @@ module Rails module Generators - class SessionMigrationGenerator < NamedBase + class SessionMigrationGenerator < NamedBase #metagenerator argument :name, :type => :string, :default => "add_session_table" hook_for :orm end |