Hi everyone.
Ive part of a project that I need to refactor, and im having some
difficultly deciding which path to take. Perhaps someone can help, I
think its primarily a design question.
A Spec consists of many Nests and many Parts. Nests contain Parts.
Here''s what I have, which works well currently:
---------------------------------------------------
class Spec << ActiveRecord::Base
has_many :parts, :through => :speclines
has_many :nests, :through => :speclines
end
class Specline << ActiveRecord::Base
belongs_to :spec
belongs_to :part
belongs_to :nest
end
class Part << ActiveRecord::Base
has_many :specs, :through => :speclines
end
class Nest << ActiveRecord::Base
has_many :specs, :through => :speclines
end
-------------------------------------
Now the question is, how do I simplfy this?
Option 1 is polymorphic associations. But do they work with has_many
:through?
Or, seeing that nests and parts are similar, should I make them children
of a parent class that I then have the association on that? What would
that look like?
Any help would be appriciated.
-Dave
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---