Keeping models in scope of an account, build method, etc.

I'm working on a hosted type app whereby most models are in the scope
of an "account". Categories belong to accounts, posts belong to
categories, comments belong to posts. However I also made posts and
comments belong to accounts as well, for two reasons -

- being able to get orphaned posts for an account (ones where the
parent category was deleted, and the foreign key is NULL)

- easy way to get posts for an account outside the scope of
@account.posts.find(:all, :order => "num_views DESC")

The problem I am having is with the build method and creating new
rows. This code will not keep the newly created post in scope with the
account (only the category):


nor will this of course:
@category = @account.categories.find(1)

I've tried to avoid setting the account_id or category_id manually in
every part of the app, but is this my only option in this case? Or is
there a more elegant way of doing this in order to ensure consistency?

Thanks for any help :slight_smile: