:events, :source => :eventable, :s..." />

Rails: has_many through with polymorphic association - will this work?

You have to do: class Person :events, :source => :eventable, :source_type => "Meal" has_many :workouts, :through => :events, :source => :eventable, :source_type => "Workout" end This will enable you to do this: p = Person. Find(1) # get a person's meals p.meals. Each do |m| puts m end # get a person's workouts p.workouts.

Each do |w| puts w end # get all types of events for the person p.events. Each do |e| puts e. Eventable end.

A Person can have many Events and each Event can have one polymorphic Eventable record. How do I specify the relationship between the Person and the Eventable record? Do I say has_many :eventables, :through => :events like I did above?

If you see an easier way to accomplish what I'm after, I'm all ears!

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions