fixed wrong ID output for many_many and has_many relations
Merge pull request #2498 from jkempff/fix-1

fixed wrong ID output for many_many and has_many relations