Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

rails g model/migrationの違い

rails g model...

main.rb
rails g model モデル名 カラム名:データ型...
rails g model Graph date:date weight:float user:references

Graphがモデル名

モデル名とテーブルとデータができる

rails g migration...

main.rb
rails g migration add_user_id_to_posts

postsテーブルにuser_idカラムを加える

rails g model
rails g migration
はいずれも
rails db:migrate を実行する必要あり

rails db:migrate

main.rb
rails db:migrate

これがないとデータベースに反映されません

wa-ma
駆け出しのエンジニア  製造業に勤務(三交代制)しながらIT企業への転職活動中 躓いたところを記事にしています。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away