I want to create slugs based on a title field, so those slugs will have to be unique.
Is there a callback method for when validates_uniqueness_of fails so that i can append a character to the end of the slug to make it unique?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sounds like this would be better as a before_create callback than a validation. It’s not actually invalid if the name’s a dupe; you just need to uniquify it.