Checking if the message header is unique with another error return - using friendly_id
So, I was trying to check first if the post header is unique before posting it. In the model, I added this line, but it doesn't do what I expected:
validates_presence_of :title, uniqueness: true
Of course, I can check before doing the message (in the controller) and if a message with that header exists to return an error message, but is this the correct way? I thought there might be a test for this.
0
source to share