Use the `in` operator to detect for `to_param` and `id` in objects

Using a path with an `id` or a `to_param` field with a value of 0 or false will result in a path that has has the output of `object.toString()` as the id, often resulting in `"[object Object]"` being set as the id. This patch will use the `in` operator to check for the existence of `to_param` and `id` fields rather than picking the first non-falsy value we can find.