Ticket #10 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

better_nested_set does not work properly (in my opinion) with single table inheritance

Reported by: tolsen@limewire.com Assigned to: somebody
Priority: major Milestone: 0.1 with tests
Component: plugin Version: 0.1
Keywords: Cc:

Description

if you use better_nested_set on a class that uses single table inheritance, then things don't work very well. this is because there are several instances of self.class in the better_nested_set code that can isolate those commands to only work with objects that are a subclass of the current object being used.

For example, let's say C < B < A < !ActiveRecord::Base

and A does "acts_as_nested_set"

then when you manipulate any object of B, self.class evaluates to B and rails adds type_conditions to every sql query, limiting the affected rows to only those objects which are of type B or C

To get around this, we need to save the class in which acts_as_nested_set is declared. I will be attaching a patch to do this

Attachments

sti-fix.patch (16.0 kB) - added by tolsen@limewire.com on 09/05/06 22:12:59.
patch of fix #10

Change History

09/05/06 22:12:59 changed by tolsen@limewire.com

  • attachment sti-fix.patch added.

patch of fix #10

10/10/06 13:33:03 changed by jcm

  • version set to 0.1.
  • component changed from component1 to plugin.
  • milestone set to 0.1 with tests.

11/09/06 21:51:59 changed by dontfall@gmail.com

Hi Tim,

FYI, this patch (http://dev.rubyonrails.org/ticket/6030) proposes a slightly different solution to the same issue.

Krishna

12/10/06 20:33:26 changed by rails

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in revision 23. We will have to be vigilant that future changes don't break STI, which would be easy to do.