Rails - single ID for multiple models

Posted by user352351 on Stack Overflow See other posts from Stack Overflow or by user352351
Published on 2010-05-27T20:39:53Z Indexed on 2010/05/27 20:41 UTC
Read the original article Hit count: 122

I'm building an app which will allow a user to scan the barcode on a 'shelf', 'box' or 'product' which will then bring up that particular item or all the associated items.

As these are all separate models with their own ID's, I need a global ID table.

I was thinking of a polymorphic table called 'barcodes'

barcodes

  • id
  • barcode_number
  • barcodable

Is there an easy way to do this? Or is polymorphic the best way?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about database