0

In rails, I could restrict certain attribute to be unique within scope but pass on nil or blank. How could I ensure uniqueness but pass on certain value?

I encrypted an attribute, so it's not nil anymore. But I do allow nil for this attribute in the model.

2
  • What do you mean by "Pass on nil or blank"? Commented Dec 29, 2015 at 19:58
  • 2
    Have you seen this question? You should be able to add any conditional logic you need to using if: ->{...}. Commented Dec 29, 2015 at 20:01

0

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.