mardi 4 août 2015

Friendly_id creating duplicate slugs for multiple objects in Rails

My Rails build contains no pathnames. The application consists of two main objects: collections and items. So if I have a link: https://foo.com/foo, this could potentially identify either a collection or an item. The difference is made clear within the context and UI flow throughout the application.

My question: is there a way to have the Friendly ID gem generate unique slugs by seeing if a slug has already been taken by another object? I understand you can generate candidates so that friendly ID will not duplicate a slug for a given object, but I need friendly ID to check both existing collection slugs and item slugs before generating a new slug.

I hope that didn't sound too confusing. To re-word more concisely: is there a method available for friendly ID to check for slugs in multiple objects before generating a new slug? Thank you for your help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire