Using HAS_MANY but using a different primary key?

Hi there,

I’m currently setting up a polymorphic relationship. Here’s how my database looks like:

commentables (base table)

  • id

comments

  • id

  • commentable_id

  • body

posts

  • id

  • commentable_id

items

  • id

  • commentable_id

I wish to set up a HAS_MANY Comment relationship in the Post and Item model. Currently, the AR uses the primary key of the Post and Item but is it possible to make it use the commentable_id field instead?