Create new Table in ruby on rails

让人想犯罪 __ 提交于 2019-12-03 23:19:32

auto-generated is not a supported column type.

Active Record supports the following database column types:

:binary
:boolean
:date
:datetime
:decimal
:float
:integer
:primary_key
:string
:text
:time
:timestamp

More info in http://guides.rubyonrails.org/migrations.html#supported-types

Rails will create the column id automatically for you, thus just edit your migration to the following

class CreateContents < ActiveRecord::Migration
  def change
    create_table :contents do |t|
      t.integer "law_id"
      t.integer "parent_id"
      t.string "titel"
      t.string "text"
      t.string "content"
      t.string "url"

      t.timestamps
    end
  end
end
giorgian

As others say, :auto-generated is not a supported column type. Also, it is not a symbol, it's an expression and it is parsed as :auto - generated.

Don't put commas in your command line call to the rails generator, that's what puts those commas in your migration.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!