here is the situation
class Entity < ActiveRecord::Base belongs_to :parent, :foreign_key => :parent_id, :class_name => 'Entity' end
class Player < Entity end
class Team < Entity has_many :players, :foreign_key => :parent_id, :class_name => 'Player' end
class Club < Entity has_many :teams, :foreign_key => :parent_id, :class_name => 'Team' has_many :players, :through => :teams, :foreign_key => :parent_id, :class_name => 'Player' end
Mysql::Error: Not unique table/alias: 'entities': SELECT count(*) AS count_all FROM `entities` INNER JOIN `entities` ON `entities`.parent_id = `entities`.id WHERE ((`entities`.parent_id = 48) AND (( (`entities`.`entity_type` = 'Team' ) ))) AND ( `entities`.`entity_type` = 'Player' )
how do get over this problem?