I am busy making a ruby on rails app.
I want to make an model that contains a text model, a picture model and a link model. Every model can have comments, But i don’t want to make different comment models for the text, picture and link model. Is it possible to make a media model witch has a subclass(or how it is called) aka: picture model, text model and link model. Or is there an other clean way to do this.
Thanks
You can create Comment model that has polymorphic association:
You can add above line to every model that needs comments. In order to have polymorphic association you need to have those columns in comments table in db:
You can also use some plugin for comments, on example this.