# STI and controllers

**URL:** <https://www.ruby-forum.com/t/sti-and-controllers/189179>\
**Category:** Rails\
**Created:** [May 26, 2010, 6:42am UTC](https://www.ruby-forum.com/t/sti-and-controllers/189179 "2010-05-26T06:42:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [May 26, 2010, 6:42am UTC](https://www.ruby-forum.com/t/sti-and-controllers/189179/1 "2010-05-26T06:42:14Z")

</div>

Hi  
This is an implementation question. I have the STI models like  
Class FileCabinet \< ActiveRecord::Base  
end  
Class TenantFileCabinet \< FileCabinet  
end  
Class CompanyFileCabinet \< FileCabinet  
end

```
And file_cabinets table is

```

| id | int(11) | NO | PRI | NULL | auto\_increment |  
| company\_id | int(11) | YES | | NULL | |  
| type | varchar(255) | YES | | NULL | |  
| tenant\_id | int(11) | YES | | NULL | |

My documents table is below(I use paperclip)

|id | int(11) | NO | PRI | NULL | auto\_increment |  
| attachment\_file\_name | varchar(255) | YES | | NULL | |  
| attachment\_content\_type | varchar(255) | YES | | NULL | |  
| attachment\_file\_size | int(11) | YES | | NULL | |  
| attachment\_updated\_at | datetime | YES | | NULL | |  
| company\_id | int(11) | YES | | NULL | |  
| attachment\_file | longblob | YES | | NULL | |

And between file\_cabinet and documents there is has\_many :through  
relation. My document\_file\_cabinets table is

| id | int(11) | NO | PRI | NULL | auto\_increment |  
| document\_id | int(11) | YES | | NULL | |  
| file\_cabinet\_id | int(11) | YES | | NULL | |  
| deleted | tinyint(1) | YES | | 0 | |  
| company\_id | int(11) | YES | | NULL | |  
| document\_name | varchar(255) | YES | | NULL | |

```
    My purpose is to add documents to company file cabinet (those

```

can be done and viewed by company admin) and each tenant also have there  
own file cabinet. To which documents are added by admin. My question is  
since this an STI which controller should I use and how? Is it file  
cabinet controller OR company\_file\_cabinets\_controller and  
tenants\_file\_cabinets\_controller? Please guide me.

Thanks in advance  
Tom
