0

I am trying to validate uniqueness on an article description. After I save it to the DB, if I retrieve it it comes back in a stripped down format (missing some chars). If I put a validator on the uniquness of the text in the desc. it doens't get called. If I do a find_by_desc it fails since the text is slightly different. Any ideas? I know the table is UTF-8, but really most of the characters are a few line endings and some dashes (-) here or there.

3
  • It appears that if I convert them to UTF before saving them, then the next time I try to save the same description, I get the error I want: i = Iconv.new('UTF-8','LATIN1') story = i.iconv(story[0]) but this feels hackish Commented Jul 8, 2010 at 3:59
  • what is the db you are using? Commented Jul 8, 2010 at 12:37
  • to my knowledge, most db cannot do comparisons or ordering with text fields due to performance reasons, and this explains why uniqueness check fails to run. Also, checking uniqueness on article description sounds strange. can you explain a bit more? Commented Jul 8, 2010 at 12:39

1 Answer 1

1

why you don't create an hash-code for that? create it before save, in validation check for the hash comparing. I don't suggest you to compare TEXT fields

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.