Re: [ruby-81] Reflecting on Associations

From: Daniel O.
Sent on: Wednesday, January 30, 2008 11:15 AM
The Component1.reflections hash is probably what you want.

- Dan

On Jan 30,[masked]:09 AM, Mike Rood <[address removed]> wrote:

Hi Guys,

 

Can anyone tell me how I can dynamically enumerate the associations defined for a model?   I'm developing an inventory application in which I need to identify the possible sub-components for any given component.  I've defined the parts explosion hierarchy through associations in the models for the various component types, e.g.

 

   Class Component1 < ActiveRecord::Base

      has_many :subcomponent1s

      has_one     :subcomponent2

      belongs_to  :supercomponent1

   end

 

To manage recursive processes, I'd like to be able to identify all the tables I need to search to grab all the possible sub-components for any component, as well as the components to which any sub-component may belong.  Does anyone know how to do that or where I might look to figure that out? 

 

Thanks,

 

Mike





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Mike Rood ([address removed]) from The East Bay Ruby Meetup Group.
To learn more about Mike Rood, visit his/her member profile
To unsubscribe or to update your mailing list settings, click here

Meetup.com Customer Service: [address removed]
632 Broadway New York NY 10012 USA



--
[address removed]
[masked] - Direct
[masked] - Office
Daniel O'Shea / ThriveSmart, LLC

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy