I have this code in rp_parts controlled in def destroy:
@repair_ticket.rp_parts.delete(@rp_part)
repair_tickets and rp_parts are HABTM.
If I do:
repair_ticket1.rp_parts
=> [#<RpPart id: 1, …">, #<RpPart id: 1,…">, #<RpPart …">]
I only want to delete one of those RpPart id:1, and not both of them. Is
it possible?
John S. wrote:
I have this code in rp_parts controlled in def destroy:
@repair_ticket.rp_parts.delete(@rp_part)
repair_tickets and rp_parts are HABTM.
If I do:
repair_ticket1.rp_parts
=> [#<RpPart id: 1, …">, #<RpPart id: 1,…">, #<RpPart …">]
I only want to delete one of those RpPart id:1, and not both of them. Is
it possible?
Consulting the API, I found that:
.delete:
Deletes the record with the given id without instantiating an object
first. If an array of ids is provided, all of them are deleted.
What if I only want to delete the first one?