Rails程式用到的一些指令碼命令

CharlesCui發表於2008-07-28
  1. 一.鐵道
  2. 1.1 建立一個Rails應用程式
  3. $ rails app_name
  4. 可選項:
  5. -d, database=xxx 指定安裝一個資料庫(mysql oracle postgresql sqlite2 sqlite3 ), 預設情況下是資料庫
  6. -r, ruby-path= 指定Ruby的安裝路徑,如果沒有指定,scripts使用env去找Ruby
  7. -f, freeze (凍結)freezes Rails在vendor/rails目錄
  8. 1.2 API Documentation
  9. $ gem_server
  10. 啟動一個WEBrick伺服器。這時候你可以透過Http://localhost:8808/ 開啟瀏覽器去檢視rails API文件
  11. 1.3 Rake
  12. rake db:fixtures:load
  13. # 載入fixtures到當前環境的資料庫
  14. # 載入指定的fixtures使用FIXTURES=x,y
  15. rake db:migrate
  16. # 遷移資料庫透過在db/migrate目錄下的指令碼.可以指定版本號透過VERSION=x
  17. rake db:schema:dump
  18. # 建立一個db/schema.rb檔案,透過AR能過夠支援任何資料庫去使用
  19. rake db:schema:load
  20. # 再入一個schema.rb檔案進資料庫
  21. rake db:sessions:clear
  22. # 清空sessions表
  23. rake db:sessions:create
  24. # 用CGI::Session::ActiveRecordStore建立一個sessions表為使用者
  25. rake db:structure:dump
  26. # 匯出資料庫結構為一個SQL檔案
  27. rake db:test:clone
  28. # 重新建立一個測試資料庫從當前環境資料庫中
  29. rake db:test:clone_structure
  30. # 重新建立測試資料庫從開發模式資料庫
  31. rake db:test:prepare
  32. # 準備測試資料庫並在入schema
  33. rake db:test:purge
  34. # 清空測試資料庫
  35. rake doc:app
  36. # 建立HTML檔案的API Documentation
  37. rake doc:clobber_app
  38. # 刪除Documentation
  39. rake doc:clobber_plugins
  40. # 刪除 plugin Documentation
  41. rake doc:clobber_rails
  42. # 刪除Documentation
  43. rake doc:plugins
  44. # 產生Documation為所有安裝的plugins
  45. rake doc:rails
  46. # 建立HTML檔案的API Documentation
  47. rake doc:reapp
  48. # 強制重新建立HTML檔案的API Documentation
  49. rake doc:rerails
  50. # 強制重新建立HTML檔案的API Documentation
  51. rake log:clear
  52. # 清空目錄log/下的所有日誌檔案
  53. rake rails:freeze:edge
  54. # Lock this application to latest Edge Rails. Lock a specific revision with REVISION=X
  55. rake rails:freeze:gems
  56. # Lock this application to the current gems (by unpacking them into vendor/rails)
  57. rake rails:unfreeze
  58. # Unlock this application from freeze of gems or edge and return to a fluid use of system gems
  59. rake rails:update
  60. # Update both scripts and public/javascripts from Rails
  61. rake rails:update:javascripts
  62. # Update your javascripts from your current rails install
  63. rake rails:update:scripts
  64. # Add new scripts to the application script/ directory
  65. rake stats
  66. # Report code statistics (KLOCs, etc) from the application
  67. rake test
  68. # Test all units and functionals
  69. rake test:functionals
  70. # Run tests for functionalsdb:test:prepare
  71. rake test:integration
  72. # Run tests for integrationdb:test:prepare
  73. rake test:plugins
  74. # Run tests for pluginsenvironment
  75. rake test:recent
  76. # Run tests for recentdb:test:prepare
  77. rake test:uncommitted
  78. # Run tests for uncommitteddb:test:prepare
  79. rake test:units
  80. # Run tests for unitsdb:test:prepare
  81. rake tmp:cache:clear
  82. # 清空tmp/cache目錄下的所有檔案
  83. rake tmp:clear
  84. # 清空session, cache, 和socket檔案從tmp/目錄
  85. rake tmp:create
  86. # 為sessions, cache, and sockets建立tmp/目錄
  87. rake tmp:sessions:clear
  88. # 清空所有在tmp/sessions目錄下的檔案
  89. rake tmp:sockets:clear
  90. # 清空所有在tmp/sessions 目錄下的ruby_sess.* 檔案
  91. 1.4 Scripts
  92. script/about
  93. # 輸出當前環境資訊
  94. script/breakpointer
  95. # 啟動斷點server
  96. script/console
  97. # 啟動交換式的Rails控制檯
  98. script/destroy
  99. # 刪除透過generators建立的檔案
  100. script/generate
  101. # -> generators
  102. script/plugin
  103. # -> Plugins
  104. script/runner
  105. # 執行一個任務在rails上下文中
  106. script/server
  107. # 啟動開發模式伺服器http://localhost:3000
  108. //以下幾個不知道怎麼去使用
  109. script/performance/profiler
  110. script/performance/benchmarker
  111. script/process/reaper
  112. script/process/spawner
  113. 1.5 Generators
  114. ruby script/generate model ModelName
  115. ruby script/generate controller ListController show edit
  116. ruby script/generate scaffold ModelName ControllerName
  117. ruby script/generate migration AddNewTable
  118. ruby script/generate plugin PluginName
  119. ruby script/generate mailer Notification lost_password signup
  120. ruby script/generate web_service ServiceName api_one api_two
  121. ruby script/generate integration_test TestName
  122. ruby script/generate session_migration
  123. 可選項:
  124. -p, --pretend Run but do not make any changes.
  125. -f, --force Overwrite files that already exist.
  126. -s, --skip Skip files that already exist.
  127. -q, --quiet Suppress normal output.
  128. -t, --backtrace Debugging: show backtrace on errors.
  129. -h, --help Show this help message.
  130. -c, --svn Modify files with subversion. (Note: svn must be in path)
  131. 1.6 Plugins
  132. script/plugin discover
  133. # discover plugin repositories
  134. script/plugin list
  135. # list all available plugins
  136. script/plugin install where
  137. # install the a

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9934490/viewspace-1007958/,如需轉載,請註明出處,否則將追究法律責任。

相關文章