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

Limiting the list size #395

Closed Tao-Galasse closed 3 years ago

Tao-Galasse commented 3 years ago

Hi!

I'm looking for a way to set a limit on a list ; for example, let's say I have a user who can only have 5 ordered profiles.

Does the gem include a feature to handle this behaviour all by itself, or should I do it myself on the application layer ?

Thank you! 😊

brendon commented 3 years ago

Hi @Tao-Galasse, there isn't any kind of limitation system in acts_as_list. You'd probably need to implement this as a database constraint (for it to be completely safe), or a before_save to abort the save after a certain limit. There might be other better ways than this too, that's just off the top of my head :)