문제

What is the Rails Migration for creating a table?

I tried this migration generator:

$ rails g migration CreateQuestions user:references question_title:string question_text:text approved:boolean

This creates a migration that seems to be missing the usual id and timestamps fields. Did I mess up my generator?

class CreateQuestions < ActiveRecord::Migration
  def change
    create_table :questions do |t|
      t.references :user, index: true
      t.string :question_title
      t.text :question_text
      t.boolean :approved
    end
  end
end
도움이 되었습니까?

해결책

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top