2011-02-25 36 views

回答

5

當然,你可以使用-p選項

ctcherry$ rails g 
Usage: rails generate GENERATOR [args] [options] 

General options: 
    -h, [--help]  # Print generator's options and usage 
    -p, [--pretend] # Run but do not make any changes 
    -f, [--force] # Overwrite files that already exist 
    -s, [--skip]  # Skip files that already exist 
    -q, [--quiet] # Suppress status output 

ctcherry$ rails g controller controllername -p 
1

關閉我的頭頂,我知道你可以創建控制器/模型,然後轉身和摧毀它。 Rails將撤消它剛剛做的所有事情。

$ rails new my_app 

$ cd my_app/ 

$ rails g controller SomeName 
    create app/controllers/some_name_controller.rb 
    invoke erb 
    create app/views/some_name 
    invoke test_unit 
    create test/functional/some_name_controller_test.rb 
    invoke helper 
    create app/helpers/some_name_helper.rb 
    invoke test_unit 
    create  test/unit/helpers/some_name_helper_test.rb 

$ rails destroy controller SomeName 
    remove app/controllers/some_name_controller.rb 
    invoke erb 
    remove app/views/some_name 
    invoke test_unit 
    remove test/functional/some_name_controller_test.rb 
    invoke helper 
    remove app/helpers/some_name_helper.rb 
    invoke test_unit 
    remove  test/unit/helpers/some_name_helper_test.rb 

HTH

+0

然後還有什麼@ctcherry剛剛發佈了:) – 2011-02-25 01:45:48

+0

沒錯,但破壞命令還就派上用場了,謝謝你的提示! – Blankman 2011-02-25 03:03:12

相關問題