0

例如,我在项目的早期创建了这个 post_controller,但我决定稍后将其销毁。

然后我用

rails destroy controller post_controller

卸下控制器。但我也想删除附加到这个控制器的视图。在这种情况下,它们是 app/views/post 文件夹中的 erb 文件。如何删除那些 erb 文件?

4

1 回答 1

3

您可以运行rails d scaffold post,但要注意这将破坏其余的脚手架元素,包括任何模型/路线/资产等。以下是它将破坏的完整列表:

⌘ ~/testapp/ rails d scaffold post
  invoke  active_record
  remove    migration.rb
  remove    app/models/post_controller.rb
  invoke    test_unit
  remove      test/unit/post_controller_test.rb
  remove      test/fixtures/post_controllers.yml
  invoke  resource_route
   route    resources :post_controllers
  invoke  scaffold_controller
  remove    app/controllers/post_controllers_controller.rb
  invoke    erb
  remove      app/views/post_controllers
  remove      app/views/post_controllers/index.html.erb
  remove      app/views/post_controllers/edit.html.erb
  remove      app/views/post_controllers/show.html.erb
  remove      app/views/post_controllers/new.html.erb
  remove      app/views/post_controllers/_form.html.erb
  invoke    test_unit
  remove      test/functional/post_controllers_controller_test.rb
  invoke    helper
  remove      app/helpers/post_controllers_helper.rb
  invoke      test_unit
  remove        test/unit/helpers/post_controllers_helper_test.rb
  invoke  assets
  invoke    coffee
  remove      app/assets/javascripts/post_controllers.js.coffee
  invoke    scss
  remove      app/assets/stylesheets/post_controllers.css.scss
  invoke  scss

编辑:

澄清一下,rails d只是rails destroy. 它也可以用作rails generate/ rails g

于 2012-10-31T01:05:01.970 回答