Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 skip validations and callbacks

I have a particularly complex model with validations and callbacks defined. The business needs now calls for a particular scenario where adding a new record requires skipping the validations and callbacks. What's the best way to do this?

like image 825
Johnny Klassy Avatar asked Sep 27 '11 16:09

Johnny Klassy


1 Answers

This works in Rails 3:

Model.skip_callback(:create) model.save(:validate => false) Model.set_callback(:create) 

(API docs and related question)

like image 50
Dinatih Avatar answered Sep 30 '22 18:09

Dinatih