79387557

Date: 2025-01-25 21:33:04
Score: 0.5
Natty:
Report link

ActiveRecord associations to the rescue!

If you add the following association to your model, all slugs that have ever been associated with it will be released when the model is destroyed (remember that this will not work if delete is used instead of destroy).

has_many :slugs, class_name: "FriendlyId::Slug", as: :sluggable, dependent: :destroy
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Goulven