I am working on a site which tracks “ferms” (read: widgets)… each
ferm belongs to one company, one company can have many ferms.
One company can also have many users with different access priveliges,
and company administrators would invite other users to access the
company’s site.
Also, one user can belong to different companies and perhaps have
different access at each company.
I’m struggling to determine how to nest the models, here is my best
guess:
User
has_many :companies, :through => :companies_users
end
Company
has_many :ferms
has_many :users, :through => :companies_users
end
The companies_users join table would have a column that describes the
access (1,2,3?) for that user at that company.
When a user logs in and wants to view his list of ferms at Company X
the Ferms#index controller would include
@ferms = Ferm.find(:all, :conditions => [“company = ?”, User.company])
Am I on the right track with this? Any help is appreciated.
SH