使用控制台将.create / MySQL插入回滚到.create到数据库表

时间:2017-05-15 22:31:25

标签: mysql ruby-on-rails

我跟随Lynda.com上的Kevin Skoglund的Rails 5 Essentials,我遇到了一个我似乎无法诊断出来的问题。我只是尝试使用rails控制台将新部分添加到我的部分表中。

当我在控制台中键入以下内容时:

section = Section.create(:name => 'Section One', :position => 1)

我得到以下内容:

(0.4ms)  SET NAMES utf8,  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
(0.2ms)  BEGIN
(0.2ms)  ROLLBACK
=> #<Section id: nil, page_id: nil, name: "Section One", position: 1, visible: false, content_type: nil, content: nil, created_at: nil, updated_at: nil> 

我试图将其插入下表:enter image description here

这是我的部分模型:

class Section < ApplicationRecord
  belongs_to :page
  has_many :section_edits
end

我不知道为什么这个插入不起作用,因为没有任何属性不能为空。表格部分&#39;行也是空的。

enter image description here

任何理由都不能让你们任何人想出来吗?看起来像一个非常剪切和干燥的插入,但由于某种原因,它不起作用?

0 个答案:

没有答案
相关问题