Don't use a column called type, it is a reserved word in rails as it
is used in Single Table Inheritance. There are workarounds but much
better not to use it if possible.
You have not told us what are the relationships between the models.
If you set these up appropriately rails will almost always generate
the joins for you. If you have to specify joins explicitly then
possibly you have not set your relationships up correctly.