Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Ruby on Rails | Controllerの削除

概要

Controllerの削除

内容

Railsの自動生成で作成したController関連ファイルをすべて削除します

rails d controller class_name method_name

dはdestroyのd。

サンプル

自動生成実行

RSpecHaml環境です。デフォルト構成ならTest,ERBが生成されます

$ rails d controller sample index
    remove  app/controllers/sample_controller.rb
     route  get "sample/index"
    invoke  haml
    remove    app/views/sample
    remove    app/views/sample/index.html.haml
    invoke  rspec
    remove    spec/controllers/sample_controller_spec.rb
    remove    spec/views/sample
    remove    spec/views/sample/index.html.haml_spec.rb
    invoke  helper
    remove    app/helpers/sample_helper.rb
    invoke    rspec
    remove      spec/helpers/sample_helper_spec.rb
    invoke  assets
    invoke    coffee
    remove      app/assets/javascripts/sample.js.coffee
    invoke    scss
    remove      app/assets/stylesheets/sample.css.scss