Forum: Ruby on Rails class associations apart from models

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Db912f6efe445bc04c923c14c4be5a76?d=identicon&s=25 Max (Guest)
on 2007-07-06 01:02
(Received via mailing list)
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

  class Resource < ActiveRecord::Base
    belongs_to :system
    attr_accessor :name
    def initialize(name,system)
      @name = name
      # add to system (?)


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

This topic is locked and can not be replied to.