Polymorphic assc. uses base_class of object instead of class

Example:

class User < ActiveRecord::Base
end

class Member < User
has_one :blog, :as => :blogable
end

class Blog < ActiveRecrod::Base
belongs_to :blogable, :polymorphic => true
end

The member.blog.blogable_type is ‘User’.
Does anybody know the reasoning for using the base_class instead of the
class name of the object

Chris M. wrote:

The member.blog.blogable_type is ‘User’.
Does anybody know the reasoning for using the base_class instead of the
class name of the object

The reason is that the RDBMS needs to do joins on the actual table,
which corresponds to the base class, not the non-existent STI child
class.

Evan

johan wrote:

belongs_to :blogable, :polymorphic => true
end

The member.blog.blogable_type is ‘User’.
Does anybody know the reasoning for using the base_class instead of the
class name of the object

The STI/Polymorphic thing is a bit of a mess at the moment, as I
understand it. This recent documentation patch:

http://dev.rubyonrails.org/changeset/5259

contains some info that might help you for now.

Chris