I want to select one user and add to it associated records such as child for this example. But only the child with a specific place_id.
This code works, but when the user doesn't have any child entry I got an error.
@user = User.includes(:child).find(params[:id],
:conditions => ["child.place_id = ?", @place_id])
Here is the error:
Couldn't find User with id=19 [WHERE (child.place_id = 0)]
Thanks !