提交 b0b5ee95 编写于 作者: J Jeremy Kemper

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
上级 74265b65
*SVN*
* Scaffold generator depends on model generator instead of duplicating it. #7222 [bscofield]
* Scaffold generator tests. #8443 [pelle]
* Generated scaffold functional tests use assert_difference. #8421 [norbert]
......
......@@ -51,7 +51,7 @@ def manifest
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 @@ def manifest
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
......
# 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
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册