Search code examples
ruby-on-railsrubydatabaseactiverecordruby-on-rails-plugins

bidirectional habtm linking


I have application with 2 groups of models - content based (news, questions) and "something" based (devices, applications etc). I need to link all models between groups - for example question may belongs to 3 different things - one application and 2 devices. The same - for news. From other side - i need to see all news articles and questions related to some application or device.

Any idea how to develop this in rails? I have only one idea - mixins that will add methods content_id and thing_id to models and join table.


Solution

  • Solved with has_many_polymorphs plugin - http://github.com/fauna/has_many_polymorphs