0

私は連想モデルを持っています。レコードを削除しようとすると返されますtrueが、レコードはまだ存在し

ます。モデルには2つの列がありkeys、3番目の列は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