LoginSignup
1
0

More than 3 years have passed since last update.

Rails学習 1日目その2

Posted at

Ruby on Rails5速習実践ガイド chapter2

2-6-1-1 Railsアプリケーションを新規作成する

$ rails new scaffold_app -d postgresql

rails new:Railsの新規ファイル作成
scaffold_app:ファイル名
-d postgresql:SQLの指定(-dはpostgreSQL用ですよという意味)

2-6-1-2 ユーザー管理機能のひな形を作る

$ bin/rails generate scaffold user name:string address:string age:integer

bin/rails:
scaffold:アプリを作る上での作業をまとめて簡単にしてくれるツール
user:モデル名(userモデル)
name:string address:string age:integer:3つの情報をテーブルに入れテーブルを作成。

Column YAMLの基本

YAMLは構造化されたデータを表現するためのフォーマット。

animal: &animal
 cat: 'ネコ'
 dog: 'イヌ'

animal_shop_1:
  <<: *animal
  hamster: 'ハムスター'

animal_shop_2:
  <<: *animal
  parrot: 'オウム'

animalを&animalとしておく
つまり&animal= cat: 'ネコ' dog: 'イヌ'となる

animal_shop_1は
<<: *animal
hamster: 'ハムスター'

つまり
 &animalとhamster: 'ハムスター'
cat: 'ネコ' dog: 'イヌ' hamster: 'ハムスター'となる

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0