# Validations Question

**URL:** <https://www.ruby-forum.com/t/validations-question/153562>\
**Category:** Rails\
**Created:** [November 18, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/validations-question/153562 "2008-11-18T20:28:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jables](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@Jables](https://www.ruby-forum.com/u/Jables)\
**Post date:** [November 18, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/validations-question/153562/1 "2008-11-18T20:28:29Z")

</div>

I have a script that is run by a cron job. It is constantly trying to  
put the same records into the database plus a few unique ones so to  
solve this I put a validates\_uniqueness\_of :title on the model. This  
has the desired effect but the script exits with error on a invalid  
validation (identical title). I want it to keep going to the next  
record. How is this accomplished?

Thanks,  
JB

---

<div class="post-metadata">

**Author:** ![Jables](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@Jables](https://www.ruby-forum.com/u/Jables)\
**Post date:** [November 18, 2008, 8:35pm UTC](https://www.ruby-forum.com/t/validations-question/153562/2 "2008-11-18T20:35:00Z")

</div>

On Nov 18, 7:27 pm, Jables [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have a script that is run by a cron job. It is constantly trying to  
> put the same records into the database plus a few unique ones so to  
> solve this I put a validates\_uniqueness\_of :title on the model. This  
> has the desired effect but the script exits with error on a invalid  
> validation (identical title). I want it to keep going to the next  
> record. How is this accomplished?

if you are using save! (which raises exceptions upon things like that)  
either rescue the appropriate exception or use save (without the  
exclamation mark) which returns true/false rather than raising  
exceptions.

Fred
