I am having two classes: Topic
and Buy::Topic
. The latter is a sub class of the former, through a foreign key (Buy::Topic.topic_id == Topic.id
). So essentially this is using class table inheritance pattern.
Buy::Topic
has its own id
and the foreign key topic_id
pointing to the parent Topic
object.
However I would like to make sure the id of Buy::Topic
to be the same as the topic_id
from the parent like this:
#<Topic id: 22598>
with
#<Buy::Topic id: 22598, topic_id:22598
Is this possible in Rails? This is better for SEO purposes, and will make it easier in dealing with Cancan's load_and_authorize_resource
(sometimes cancan use the wrong id of the two to find stuffs).
UDPATE:
This schema has been set and done for a long time, so it's unlikely to change it to STI now.