I'm new to rails and I'm facing a problem with how to set up my models.
- I've got a set of models: Balloon, Paint, Brush etc.
- They have common attributes (like "name")
- I want them to have a unique id. That is I want that if there is an instance of Balloon with an id=NNN, then Paint.find(NNN) and Brush.find(NNN) return nil.
An obvious solution would be to create a model, say Item, which Balloon, Paint and Brush are inherited from. But this approach sort of smells, because subclasses Balloon, Paint and Brush are indeed quite different. The only thing I need from them is that id attribute be unique among these subclasses.
I've heard about composition and delegation in Rails but I'm not fluent with them, so I don't know what is the reasonable way to resolve the problem.