Hello, I''ve been googling for about two hours already but not successful yet so I hope you guys can help me out. I need some kind of n:m polymorphic relation like this: building_types: living, shops block_types: residential, commercial activity_types: act1, act2 So now I need a connection table e.g. activity_scope so I can for example allow act1 only for living and residential and act2 for commercial and shops Any ideas? -- 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-/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.
Hi Heinz, can you explain a bit more what is the goal? I''m not an expert, so maybe I misunderstood. What is wrong with ''has_many'' and ''belongs_to'' models? If a record can have many types, which defined in other database, then it can be explicitly defined in the model which it belongs to with these. (I''m not sure if you thought about this.) I think check Active Record, and how to use it, your answer will be there for sure! (Agile Web Development with Rails have 3 deep chapter about it ;)) Let me know how is your problem going, all the bests, gezope 2010/9/1 Heinz Strunk <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>> Hello, > > I''ve been googling for about two hours already but not successful yet so > I hope you guys can help me out. > > I need some kind of n:m polymorphic relation like this: > building_types: living, shops > block_types: residential, commercial > > activity_types: act1, act2 > > So now I need a connection table e.g. activity_scope so I can for > example allow > act1 only for living and residential and act2 for commercial and shops > > Any ideas? > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@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.
Heinz Strunk wrote:> Hello, > > I''ve been googling for about two hours already but not successful yet so > I hope you guys can help me out. > > I need some kind of n:m polymorphic relation like this: > building_types: living, shops > block_types: residential, commercial > > activity_types: act1, act2 > > So now I need a connection table e.g. activity_scope so I can for > example allow > act1 only for living and residential and act2 for commercial and shops > > Any ideas?This doesn''t sound like a polymorphic relationship (at least not in terms of tables). Are living, shop, residential and commercial each models, or just attribute values for a building model (living or shop) and a block model (residential or commercial)? It feels like this is more just a case of a complex validation where you need to check the building type of a related building and the block_type of a related block according to the activity type. -- 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-/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.