Adding nested belongs_to

Fixes #3274
I initially created a pull request with non descriptive branch name on #3276

Now it's okay.
Another PR that attempted to solve this was #2546 but I think it's a little bit out of date.

Hope you enjoy.