- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我刚开始学习 Rails,如果这个问题的答案很明显,我很抱歉。
我已经在我的应用程序中添加了对帖子和类别表的迁移,现在我使用以下行在我的帖子表中添加对默认值非空的类别的引用:
add_reference :posts, :category, index: true, foreign_key: true, null: false
但是我在运行迁移时遇到以下错误:
SQLite3::SQLException: Cannot add a NOT NULL column with default value NULL: ALTER TABLE "posts" ADD "category_id" integer NOT NULL
我已经尝试通读 API,但无法弄清楚我做错了什么。
最佳答案
也许 sqlite3 不允许这样做,尝试
add_reference :posts, :category, index: true, foreign_key: true, null: false
change_column :posts, :category_id, :integer, null: false
关于ruby-on-rails - Rails4 迁移-添加 null : false to an add_reference method?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32305821/
我正在尝试使用类型特征来添加对模板参数的引用。 template struct S { typename add_reference::type reference; // reference me
我正在查看 [VC10 的] unique_ptr,它们做了一些我不明白的事情: typedef typename tr1::remove_reference::type _Dx_noref; _Dx
我有以下迁移 class LinkDoctorsAndSpecializations 'index name' 中指定的那样 最佳答案 作为我commented , 做: add_index :ta
向上迁移这个迁移 def change remove_reference :order_items, :order, foreign_key: true end 或向下迁移此迁移 def ch
rails 中的"add_foreign_key" 和"add_reference" 方法有什么区别? 根据rails official guide,我的理解是它们都用于在两个表之间创建外键约束。 最
在 Rails 5 和 PostgreSQL 中。 我创建这个文件是为了默认使用 bigint 数据类型而不是 integer: # config/initializers/bigint_primar
我刚开始学习 Rails,如果这个问题的答案很明显,我很抱歉。 我已经在我的应用程序中添加了对帖子和类别表的迁移,现在我使用以下行在我的帖子表中添加对默认值非空的类别的引用: add_referenc
我有以下两个模型: class Store < ActiveRecord::Base belongs_to :person end class Person < ActiveRecord::B
我是一名优秀的程序员,十分优秀!