Is there a better way to do this? It looks really ugly! http://pastie.org/1640550 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sorry if this feel as an ''up'', but I felt I needed to provide a more thorough explanation about what I want to accomplish. I''m developing a game set on Star Wars universe. On this game, I''ll have Squadron that can buy Units to compose Fleets, provide they can (check with a habtm association between Squad and Unit). But we now need an extra layer of complexity upon this. We have a new kind of Unit called Facility, which will produce a kind of Unit. I am creating a new class for Fleets composed of Facilities as well. So, Squad can have Fleets and FacilityFleets (has_many for both), and HABTM on Units and Facilities. What I''ve come up so far is: I have a GenericUnit which Unit and Facility inherits from, and a GenericFleet which Fleet and FacilityFleet inherits from. My problem is that I don''t know how to set up these relationships. I''ve stuck on the GenericUnit/Unit/Facility problem. I''ve kinda solved this as showed here: http://pastie.org/1640550. But this doesn''t look like the right way to solve this. I''m pretty sure there is a smarter way of doing this. Thanks for your help! On Sun, Mar 6, 2011 at 17:51, Lunks <pnascimento-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is there a better way to do this? It looks really ugly! > http://pastie.org/1640550 >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Are Facility and Unit really both types of GenericUnit? What do they have in common? Do they really need the same parent class? On Sunday, March 6, 2011 8:57:10 PM UTC-5, Pedro Nascimento wrote:> > I have a GenericUnit which Unit and Facility inherits from >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks for the reply! And yeah, they are. GenericUnit was actually created to handle the similarities, after we thought of the Facility type. They can both be captured, and costs money, are looked upon at when registering attacks, etc. Code is on http://github.com/lunks/wargame, if you''d like to take a look. On Mon, Mar 7, 2011 at 14:40, Tim Shaffer <timshaffer-BUHhN+a2lJ4@public.gmane.org> wrote:> Are Facility and Unit really both types of GenericUnit? What do they have > in common? Do they really need the same parent class? > > > On Sunday, March 6, 2011 8:57:10 PM UTC-5, Pedro Nascimento wrote: >> >> I have a GenericUnit which Unit and Facility inherits from >> > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.