I have a associative model, when I try to delete a record it returns true
but the record still exists,
The Model has 2 columns which are keys
, while the third column is an enum
, also a key.
Any tips relating to updating/deleting a associative model in 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
Inside racksh
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