Arrange inherited model when using STI #118

Closed
Darkside73 opened this Issue Feb 25, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@Darkside73
class Page < ActiveRecord::Base
  has_ancestry
end
class Category < Page
end

To get all arranged categories I have to use Page model with condition:

Page.where(type: 'Category').arrange

Unfortunately this does not work and returns all records (including Page models)

Category.arrange

But

Category.roots

adds condition by type

It would by handy if "arrange" will provide same behavior

@StefanH

This comment has been minimized.

Show comment Hide comment
@StefanH

StefanH Apr 3, 2013

Collaborator

Arrange will indeed ignore STI. I assume this is by design, since arrange needs all records to provide a correct result. If you don't want this behaviour you can overwrite the arrange method in your model, it's fairly straightforward.

Collaborator

StefanH commented Apr 3, 2013

Arrange will indeed ignore STI. I assume this is by design, since arrange needs all records to provide a correct result. If you don't want this behaviour you can overwrite the arrange method in your model, it's fairly straightforward.

@StefanH StefanH closed this Apr 3, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment