我创建了一个项目,显示他们演奏的音乐会,乐队和剧集。我搭建了一个名为Set
的模型,这显然是我的愚蠢,因为Ruby中已经有一个Set
类。
所以,我的问题是:解决这个问题的最佳方法是什么?我应该摧毁脚手架吗?这是我唯一的选择,真的吗?
答案 0 :(得分:2)
您可以重命名所有文件(和类),但破坏脚手架会更快:)
答案 1 :(得分:0)
当您使用脚手架时,会创建一个迁移。您可以向下迁移版本以回滚Set scaffold(如果您已经执行了db:migrate):
./script/generate scaffold Set foo:string bar:string
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/sets
exists app/views/layouts/
exists test/functional/
exists test/unit/
create test/unit/helpers/
exists public/stylesheets/
create app/views/sets/index.html.erb
create app/views/sets/show.html.erb
create app/views/sets/new.html.erb
create app/views/sets/edit.html.erb
create app/views/layouts/sets.html.erb
create public/stylesheets/scaffold.css
create app/controllers/sets_controller.rb
create test/functional/sets_controller_test.rb
create app/helpers/sets_helper.rb
create test/unit/helpers/sets_helper_test.rb
route map.resources :sets
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/set.rb
create test/unit/set_test.rb
create test/fixtures/sets.yml
create db/migrate
create db/migrate/20110328204128_create_sets.rb
小心这一行:
create db/migrate/20110328204128_create_sets.rb
它提供迁移次数:20110328204128
要回滚交易:
rake db:migrate:down VERSION=20110328204128
最后一步:
正如flOOr所说:
您可以重命名所有文件(和类),但破坏脚手架会更快:)