This project is archived and is in readonly mode.

#671 ✓resolved
Daniel Guettler

Full STI class name in associations

Reported by Daniel Guettler | July 21st, 2008 @ 08:37 PM | in 2.x

When using namespaced models together with has_many and :joins in find the demodulized class name is used instead of the full class name even so the "store_full_sti_class" option is set to "true".


module Namespaced
  class Firm < ::Company
    has_many :clients, :class_name => 'Namespaced::Client'

  class Client < ::Company

Namespaced::Firm.find(:all, {
  :select => "#{Namespaced::Firm.table_name}.id, COUNT(#{Namespaced::Client.table_name}.id)",
  :joins => :clients,
  :group => "#{Namespaced::Firm.table_name}.id"

will use type = 'Client' instead of type = 'Namespaced::Client'

Patch with tests attached.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>


Referenced by