[指令] The Rails Command Line Interface (CLI)
在 Rails cli 中,有時候會看到使用 rails
,有時候用 bin/rails
。如果是直接輸入 rails ,則它會在系統中的任何地方尋找到名為 rails 的執行檔並執行,因此如果你的系統安裝多於一個版本的 rails 時,這麼做可能會出問題,因此建議除了建立新專案時,其他時候都使用 bin/rails 指令開頭。
# 建立專案
rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
rails active_storage:install
rails generate scaffold Product title:string description:text image_url:string price:decimal