# Class associations apart from models

**URL:** <https://www.ruby-forum.com/t/class-associations-apart-from-models/108687>\
**Category:** Rails\
**Created:** [July 6, 2007, 1:02am UTC](https://www.ruby-forum.com/t/class-associations-apart-from-models/108687 "2007-07-06T01:02:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![max](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e5b9ba/32.png) [@max](https://www.ruby-forum.com/u/max)\
**Post date:** [July 6, 2007, 1:02am UTC](https://www.ruby-forum.com/t/class-associations-apart-from-models/108687/1 "2007-07-06T01:02:41Z")

</div>

I want to use several custom classes in the controller. Some of them  
are supposed to have certain associations. I know how to work with  
associations in the model and I thought that I could do something  
similar here.

What I tried is something like this:

module Types

class System \< ActiveRecord::Base  
has\_many :resources  
attr\_accessor :name  
def initialize(name)  
@name = name  
end  
end

class Resource \< ActiveRecord::Base  
belongs\_to :system  
attr\_accessor :name  
def initialize(name,system)  
@name = name  
# add to system (?)  
end  
end

end

So how can I specity the System for a Resource or return it?

Thanks,  
Max
