# Associating (or scoping) information with currently logged i

**URL:** <https://www.ruby-forum.com/t/associating-or-scoping-information-with-currently-logged-i/113579>\
**Category:** Rails\
**Created:** [September 2, 2007, 4:57am UTC](https://www.ruby-forum.com/t/associating-or-scoping-information-with-currently-logged-i/113579 "2007-09-02T04:57:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gberz3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f9ae1b/32.png) [@gberz3](https://www.ruby-forum.com/u/gberz3)\
**Post date:** [September 2, 2007, 4:57am UTC](https://www.ruby-forum.com/t/associating-or-scoping-information-with-currently-logged-i/113579/1 "2007-09-02T04:57:16Z")

</div>

Hi All,

I’m currently developing a multi-user/multi-company invoice/billing  
application in Rails. I haven’t implemented any kind of scoping  
because I can’t figure out the most intelligent mechanism by which to  
do it. I need to be able to associate all “Invoices”,  
“Invoice\_items”, “Clients”, “Products”, “Services” – well, you get  
the idea – with the currently logged in “Company”. I fail to believe  
that _manually_ adding a “company\_id” to every single table is the  
best solution. Can you recommend any mechanism (or plugin) by which  
to accomplish site-wide scoping?

Basically I need to do what so many others (e.g. Basecamp, Shopify,  
etc) are already doing; simply with an invoicing/billing twist. I’m  
not sure if they’re creating completely separate “installs” each time  
a company is created, or if everything is being stored in a single DB  
and being managed via associations. If the latter, are they tediously  
adding “company\_id” to “E-V-E-R-Y S-I-N-G-L-E A-S-S-O-C-I-A-T-E-D T-A-  
B-L-E”?

Thanks,  
Michael

---

<div class="post-metadata">

**Author:** ![gberz3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f9ae1b/32.png) [@gberz3](https://www.ruby-forum.com/u/gberz3)\
**Post date:** [September 2, 2007, 1:04pm UTC](https://www.ruby-forum.com/t/associating-or-scoping-information-with-currently-logged-i/113579/2 "2007-09-02T13:04:50Z")

</div>

Perhaps this is what I’m looking for?:

[http://elctech.com/content/scope-controller-model](http://elctech.com/content/scope-controller-model)
