brendon / acts_as_list

An ActiveRecord plugin for managing lists.
http://brendon.github.io/acts_as_list/
MIT License
2.05k stars 356 forks source link

Fix regression with using acts_as_list on base classes #147

Closed botandrose closed 9 years ago

botandrose commented 9 years ago

https://github.com/swanandp/acts_as_list/pull/123 introduced a regression, since acts_as_list_class now returns the subclass, not the superclass. My use-case is as follows:

class Segment < AR::Base
  acts_as_list
end

class Video < Segment; end
class Quiz < Segment; end
class Exam < Segment; end

The application is an online course, which is composed of videos, quizzes, and exams. acts_as_list keeps these in order. However, after https://github.com/swanandp/acts_as_list/pull/123, lower_item will return the next item of the same subclass, skipping over other segments of other subclasses, which is not at all desired.

If one desires this behavior, declaring acts_as_list on the subclasses separately makes sense. This PR reverts the regression, and includes tests for both use-cases.

swanandp commented 9 years ago

@botandrose We want to support Rubinius as well, but the issue is about bundler and rbx versioning, so I'll let it slide for now.

botandrose commented 9 years ago

Thank you for the quick response! <3

severin commented 9 years ago

Thanks for fixing this! Just ran into the same issue.