use polymorphic association. drop your taggings model. add tag_id and tag_type to your tag model and set it up as a polymorphic associaton for each model you want to add a tag to.
side: if you're adding tags to models, I suggest you look at acts_as_taggable_on https://github.com/mbleigh/acts-as-taggable-on On Mon, Feb 21, 2011 at 1:27 AM, Alireza Savand <[email protected]>wrote: > hi. > > > i have 3 model or better saying 3 db table > 1.Post > 2.Tag > 3.Taggings > > in Post => { title, content} > in Tag => {name} > in Tagging => {tag_id, post_id} > > so it's easy for gathering tags for each post by using => > post.taggings.tags > okay! > > now if i have another table(model), for example (News, Article, Job), in > this situation how can i improve Tag and Tagging model for working with > them. > it's mean i have to change Tagging to => {tag_id, post_id, news_id, > article_id, job_id} ? > i can't figure out... > > tnx ! > > -- > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

