cssruby-on-railsrubyacts-as-list

How to make acts_as_list make the added item have the top position?


I have a group of items which uses the acts_as_list gem. As of now, when a new item is added, acts_as_list will give the item the lowest position, making it show up as the last item on the list. Is there a way to make it so that acts_as_list gives the newly added item a position number which makes it show up 1st rather than last? I don't want to flip the positions of the other items though. Thanks!


Solution

  • New entries in a list are by default added to the bottom. You can specify the add_new_at option to have new entries added at the top:

    acts_as_list scope: :object, add_new_at: :top
    

    Hope it helps!