0

我有一个关联模型,当我尝试删除它返回true的记录但该记录仍然存在时,

该模型有 2 列是keys,而第三列是enum,也是一个键。

有关在 DataMapper 中更新/删除关联模型的任何提示

class A
   #some property definition
end

class B
   #some property definition
end

class C
  include DataMapper::Resource
  include DataMapper::Grape::Resource

  expose :type

  property :type, Enum[:a, :b], :key => true, :unique => false

  belongs_to :a, :key => true
  belongs_to :b, :key => true

end

内部机架

element = C.get(:a,1,1)
# => returns Hash Object
# Fine till now
element.destroyed?
# => true
# I dont know why did it return true, I am 100% sure I havent performed destroy or destroy! on element
element.type
# => :a
element.type = :b
# => DataMapper::ImmutableError: Immutable resource cannot be modified
element.destroy!
# => true
C.get(:a,1,1)
# => the same Hash Object rather than returning nil
4

0 回答 0