rails generate
Generate new Rails templates in an existing project. More information: https://guides.rubyonrails.org/command_line.html#bin-rails-generate.
- List all available generators:
rails generate
- Generate a new model named Post with attributes title and body:
rails generate model
- Generate a new controller named Posts with actions index, show, new, and create:
rails generate controller
- Generate a new migration that adds a category attribute to an existing model called Post:
rails generate migration
- Generate a scaffold for a model named Post, predefining the attributes title and body:
rails generate scaffold
来源:tldr-pages contributors · 作者与贡献记录 · CC BY 4.0。离线整理了版式、链接和媒体显示。
