I want to check if a claim's items has assets in it and @item_assets basically gets all the items in the database that are classified as assets.
When doing the following:
>> @claim.items
=> [#<Item id: 8, name: "chair", amount: 10.0, gst: 0.7, override: false, item_category_id: 7, item_expense_id: 8, claim_id: 8, club_id: 71, created_at: "2009-10-18 10:16:10", updated_at: "2009-10-18 10:16:10">, #<Item id: 9, name: "soemthing", amount: 20.0, gst: 1.4, override: false, item_category_id: 7, item_expense_id: 7, claim_id: 8, club_id: 71, created_at: "2009-10-18 10:16:10", updated_at: "2009-10-18 10:16:10">]
>> @items_assets
=> [#<Item id: 8, name: "chair", amount: 10.0, gst: 0.7, override: false, item_category_id: 7, item_expense_id: 8, claim_id: 8, club_id: 71, created_at: "2009-10-18 10:16:10", updated_at: "2009-10-18 10:16:10">, #<Item id: 9, name: "soemthing", amount: 20.0, gst: 1.4, override: false, item_category_id: 7, item_expense_id: 7, claim_id: 8, club_id: 71, created_at: "2009-10-18 10:16:10", updated_at: "2009-10-18 10:16:10">]
>> @claim.items.include? @items_assets
=> false
The result puzzles me. After investigation I realize that the items on both arrays are of different object even though they refer to the same id.
As such, it appears that include? can no longer work in this case.
Can someone suggest how else should I go about checking if a claim's items have assets in it?
Claim HM Items
Items BT Claim