i just ran into a problem with some test, and i am not exactly sure why,
but the difference happened when i changed my model validation from:
validate :custom_validation
to:
validate_on_create :custom_validation
can someone give me any ideas on where in the chain the validation takes
place?
thanks!
On Thu, Apr 28, 2011 at 3:06 PM, Sergio R. [email protected]
wrote:
place?
This is really a Rails or ActiveRecord question rather than RSpec.
In any case.
validate :custom_validation
will run the custom_validation method whether the model is being
created or updated.
validate_on_create :custom_validation
will only run the custom_validation method when the method is being
created.
There’s also a validate_on_update method which will run the custom
validation method when the model is being updated but not when it is
created.
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Github: rubyredrick (Rick DeNatale) · GitHub
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
thanks, nick… i looks like i need to hunt around a bit more as to what
was causing my problem…
thanks!
On Thu, Apr 28, 2011 at 2:06 PM, Sergio R. [email protected]
wrote:
place?
thanks!
–
Posted via http://www.ruby-forum.com/.
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users
validate
will run that validation on create and update.
validate_on_create
will only run on creation.