Here is the rails 3 query in the app:
Order.where('id IN (?)',ContractItem.where(contract_id: @contract.id).select('contract_item_id'))
Here is the only record in contract_item table:
As shown in the record, the @contract.id is equal to 1 and we expect ContractItem.where(contract_id: @contract.id).select('contract_item_id') returns array [2].
So Order.where('id IN (?)',ContractItem.where(contract_id: @contract.id).select('contract_item_id'))should return order#2. However what we have got is nothing. We figure an empty array must be returned instead. Is there something wrong with the code above?