I have an app that uses subdomains for each 'account'.
From what I have read it is good practice to "Tie all top-level requests off the current account (subdomain)".
e.g.
def find_users
@users = @current_account.users
end
Simple enough. But when I start having deeply nested routes, I can't use shallow routing without losing the scope of the subdomain.
So how do I achieve shallow routing and keep this integrity?
The only things I have thought of are:
To include a foreign key to the top level (subdomain) in some of the more deeply nested models. But this seems a bit of a hack.
To use a before_filter to backtrack up the associations and check that the subdomain holds true. This seems more logical but still feels not great.
Does anyone have a take on this?