$ rails new scaffold_app -d postgresql
rails new: Create a new Rails file scaffold_app: file name -d postgresql: SQL specification (-d means postgreSQL)
$ bin/rails generate scaffold user name:string address:string age:integer
bin/rails: scaffold: A tool that makes it easy to put together the work of creating an app user: model name (user model) name: string address: string age: integer: Create a table by putting 3 pieces of information into the table.
YAML is a format for representing structured data.
animal: &animal
cat: 'cat'
dog: 'Dog'
animal_shop_1:
<<: *animal
hamster: 'hamster'
animal_shop_2:
<<: *animal
parrot: 'Parrot'
Keep animal as & animal So & animal = cat:'cat' dog:'dog'
animal_shop_1 is <<: *animal hamster:'hamster'
In other words & Animal and hamster:'hamster' cat:'cat' dog:'dog' hamster: become'hamster'
Recommended Posts