Update cheatsheets

This commit is contained in:
ivuorinen
2024-02-21 11:19:49 +00:00
parent 4e88a1b42f
commit 3d653cc7e6
4803 changed files with 127002 additions and 0 deletions

29
rails-generate Normal file
View File

@@ -0,0 +1,29 @@
---
syntax: markdown
tags: [tldr, common]
source: https://github.com/tldr-pages/tldr.git
---
# 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 {{Post}} {{title:string}} {{body:text}}`
- Generate a new controller named Posts with actions index, show, new and create:
`rails generate controller {{Posts}} {{index}} {{show}} {{new}} {{create}}`
- Generate a new migration that adds a category attribute to an existing model called Post:
`rails generate migration {{AddCategoryToPost}} {{category:string}}`
- Generate a scaffold for a model named Post, predefining the attributes title and body:
`rails generate scaffold {{Post}} {{title:string}} {{body:text}}`