diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-25 21:15:46 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-25 21:15:46 +0000 |
commit | b0b5ee958ae59f3f85c538d133f38d069e9052f5 (patch) | |
tree | fa02dfe5717ad5c65f0d10888d9656f14d9f1d8b /railties/lib | |
parent | 74265b650154197e6d4bc197d5c3eac3189e7942 (diff) | |
download | rails-b0b5ee958ae59f3f85c538d133f38d069e9052f5.tar.gz rails-b0b5ee958ae59f3f85c538d133f38d069e9052f5.tar.bz2 rails-b0b5ee958ae59f3f85c538d133f38d069e9052f5.zip |
Scaffold generator depends on model generator instead of duplicating it. Closes #7222.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6840 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
4 files changed, 1 insertions, 40 deletions
diff --git a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb index 8a331867eb..11c80d2020 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +++ b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb @@ -51,7 +51,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase m.template('layout.html.erb', File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.html.erb")) m.template('style.css', 'public/stylesheets/scaffold.css') - m.template('model.rb', File.join('app/models', class_path, "#{file_name}.rb")) + m.dependency 'model', [singular_name] + @args, :collision => :skip m.template( 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb") @@ -59,19 +59,6 @@ class ScaffoldGenerator < Rails::Generator::NamedBase m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb")) m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb")) - m.template('unit_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")) - m.template('fixtures.yml', File.join('test/fixtures', "#{table_name}.yml")) - - unless options[:skip_migration] - m.migration_template( - 'migration.rb', 'db/migrate', - :assigns => { - :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}", - :attributes => attributes - }, - :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}" - ) - end m.route_resources controller_file_name end diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/fixtures.yml b/railties/lib/rails_generator/generators/components/scaffold/templates/fixtures.yml deleted file mode 100644 index 9f5ae29a81..0000000000 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/fixtures.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -one: - id: 1 -<% for attribute in attributes -%> - <%= attribute.name %>: <%= attribute.default %> -<% end -%> -two: - id: 2 -<% for attribute in attributes -%> - <%= attribute.name %>: <%= attribute.default %> -<% end -%>
\ No newline at end of file diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/migration.rb b/railties/lib/rails_generator/generators/components/scaffold/templates/migration.rb deleted file mode 100644 index cb1ddd399e..0000000000 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/migration.rb +++ /dev/null @@ -1,13 +0,0 @@ -class <%= migration_name %> < ActiveRecord::Migration - def self.up - create_table :<%= table_name %> do |t| -<% for attribute in attributes -%> - t.<%= attribute.type %> :<%= attribute.name %> -<% end -%> - end - end - - def self.down - drop_table :<%= table_name %> - end -end diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/model.rb b/railties/lib/rails_generator/generators/components/scaffold/templates/model.rb deleted file mode 100644 index 8d4c89e912..0000000000 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/model.rb +++ /dev/null @@ -1,2 +0,0 @@ -class <%= class_name %> < ActiveRecord::Base -end |