Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Full STI class name in associations

#671

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".

Example:

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

  class Client < ::Company
  end
end

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.

Reported by Daniel Guettler · July 21st, 2008 @ 08:37 PM

State: resolved
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: Low

Activity

  1. Pratik
    Pratik
    • Assigned user set to Pratik

    July 22nd, 2008 @ 01:20 AM

  2. Christian Weyer
    Christian Weyer
    • Assigned user cleared.

    this is a duplicate of #465 Full class name STI not included in eager loading which is already resolved

    July 22nd, 2008 @ 01:21 AM

  3. Christian Weyer
    Christian Weyer
    • Assigned user set to Pratik

    July 22nd, 2008 @ 01:24 AM

  4. Repository
    Repository
    • State changed from new to resolved

    (from [c67713a2fe78d6f2db49b09771841f5022995703]) Use klass.sti_name to make sure associations take store_full_sti_class into account. [#671 state:resolved]

    Signed-off-by: Pratik Naik

    http://github.com/rails/rails/co...

    July 22nd, 2008 @ 01:26 AM

  5. Pratik
    Pratik
    • State changed from resolved to new

    Christian Weyer : It's similar, not duplicate.

    Thanks.

    July 22nd, 2008 @ 01:29 AM

  6. Pratik
    Pratik
    • State changed from new to resolved

    July 22nd, 2008 @ 01:30 AM

  7. Repository
    Repository

    (from [c2f1918990b82516b1bf6142274e892df776ffff]) Use klass.sti_name to make sure associations take store_full_sti_class into account. [#671 Full STI class name in associations state:resolved]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...

    August 25th, 2008 @ 09:28 AM

  8. Ryan Bigg
    Ryan Bigg
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 11th, 2010 @ 10:53 AM