brendon / acts_as_list

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

Attachments sorting / has_many_attached #403

Closed Bar2d2 closed 2 years ago

Bar2d2 commented 2 years ago

Hi, acts_as_list is great! But lately I was wondering is it possible to use it to sort ActiveStorage Attachments?

In my model I have:

has_many_attached :photos acts_as_list scope: [:photos]

but still getting error NoMethodError - undefined method `insert_at'.

Thank's in advance for any help.

brendon commented 2 years ago

Hi @Bar2d2, in my experience you'd need to create an intermediate model of your own called Photo that has_one_attached :file and acts_as_list scope: :parent_thing_id`. That would allow you to order your photos.