petehamilton / citier

CITIER (Class Inheritance & Table Inheritance Embeddings for Rails) is a solution for simple Multiple Class Inheritance in Rails.
88 stars 24 forks source link

Delegate reflect_on_association to root class #63

Closed bigfive closed 1 year ago

bigfive commented 12 years ago

Delegate reflect_on_association to the citier root class if a reflection is not found on the child class. This is needed for polymorphic associations The below will fail without the proposed change

class Node < ActiveRecord::Base
  acts_as_citier
  has_many :comments, :as => :commentable
end

class Page < Node
  acts_as_citier
end

class Comment < ActiveRecord::Base
  belongs_to :commentable, :polymorphic => true
end

Page.first.comments # NoMethodError: undefined method `association_class' for nil:NilClass