If I want to generate a random string for a token in rails, can I use validates_uniqueness_of on it? Given that this isn't something a user will input or get an error back for it needs to be unique straight away. Or am I just being stupid?
A:
validates_uniqueness_of will just make sure that the attribute is unique - it won't generate the value.
I'd use before_validation to create the unique value.
Mr. Matt
2009-05-15 11:21:31
Might give that a go. Thanks
Cameron
2009-05-15 22:15:03