回滚到Savepoint rails 4

时间:2013-11-04 17:25:16

标签: ruby-on-rails associations

这里是rails的新手。在尝试在rails控制台中创建记录时,我收到了这条消息:

(0.0ms)  SAVEPOINT active_record_1
(0.0ms)  ROLLBACK TO SAVEPOINT active_record_1
=> false

我不知道如何调试但不知道从哪里开始。这是我的模特

class User < ActiveRecord::Base
  has_many :occurrences 
  has_many :created_submissions,
           foreign_key: "creator_id",
           class_name: "Version"
  end

class Occurrence < ActiveRecord::Base
  belongs_to :template, autosave: true
  belongs_to :user
  has_many :versions

end

我正在尝试使用以下方法创建记录:

new_user = User.new
user = User.first
new_user.occurrences.build(user: user.id)
new_user.save

有人对此有所了解吗?

0 个答案:

没有答案