You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You'll have a number of methods added to each instance of the ActiveRecord model that to which `acts_as_list` is added.
36
+
37
+
In `acts_as_list`, "higher" means further up the list (a lower `position`), and "lower" means further down the list (a higher `position`). That can be confusing, so it might make sense to add tests that validate that you're using the right method given your context.
38
+
39
+
### Methods That Change Position and Reorder List
40
+
41
+
-`list_item.insert_at(2)`
42
+
-`list_item.move_lower` will do nothing if the item is the lowest item
43
+
-`list_item.move_higher` will do nothing if the item is the highest item
44
+
-`list_item.move_to_bottom`
45
+
-`list_item.move_to_top`
46
+
-`list_item.remove_from_list`
47
+
48
+
### Methods That Change Position Without Reordering List
49
+
50
+
-`list_item.increment_position`
51
+
-`list_item.decrement_position`
52
+
-`list_item.set_list_position(3)`
53
+
54
+
### Methods That Return Attributes of the Item's List Position
55
+
-`list_item.first?`
56
+
-`list_item.last?`
57
+
-`list_item.in_list?`
58
+
-`list_item.not_in_list?`
59
+
-`list_item.default_position?`
60
+
-`list_item.higher_item`
61
+
-`list_item.lower_item`
62
+
33
63
## Notes
34
64
If the `position` column has a default value, then there is a slight change in behavior, i.e if you have 4 items in the list, and you insert 1, with a default position 0, it would be pushed to the bottom of the list. Please look at the tests for this and some recent pull requests for discussions related to this.
35
65
36
66
All `position` queries (select, update, etc.) inside gem methods are executed without the default scope (i.e. `Model.unscoped`), this will prevent nasty issues when the default scope is different from `acts_as_list` scope.
37
67
68
+
The `position` column is set after validations are called, so you should not put a `presence` validation on the `position` column.
69
+
38
70
## Versions
39
71
All versions `0.1.5` onwards require Rails 3.0.x and higher.
0 commit comments