いつもお世話になります。
現在rails g コマンドを下記の通り実行した後、db/migrate/内のファイルを以下のように書き換えてrake db:migrateを実行しています。
書き換えている部分は「 t.integer :likes_count」の後ろにオプションとして「, :null => false, :default => 0」を付け加えています。
Ruby
1 2実行コマンド 3rails g model xxxx poster_name:string likes_count:integer poster_account_name:string 4 5class CreateXxxxxs < ActiveRecord::Migration[5.1] 6 def change 7 create_table :xxxxs do |t| 8 t.string :poster_name 9 t.integer :likes_count, :null => false, :default => 0 10 t.string :poster_account_name 11 12 t.timestamps 13 end 14 end 15end 16 17
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/24 09:40
2018/01/24 09:52
2018/01/25 01:45