search for: validation_method

Displaying 3 results from an estimated 3 matches for "validation_method".

2005 May 04
1
Conditional validations
...ng line: if options[:if] and record.send(options[:if]) ... so that validates_each now looks like this: def validates_each(*attrs) options = attrs.last.is_a?(Hash) ? attrs.pop.symbolize_keys : {} attrs = attrs.flatten # Declare the validation. send(validation_method(options[:on] || :save)) do |record| if options[:if] and record.send(options[:if]) attrs.each do |attr| value = record.send(attr) next if value.nil? && options[:allow_nil] yield record, attr, value end end...
2005 Apr 23
7
Validation question
Hi all, Is there a way to invoke validations at times other than save, create and update? I know that I can do this by writing my own validation checks using errors.add_[blah], but I''d like to leverage the existing validation code. What I have is two sets of fields in a record, set A and set B. Both sets must be validated on record create. However, the trouble is that after
2006 May 23
11
putting the schema in the model files
THE SCHEMA IN THE MODEL a small write up on ''putting the schema in the model'' This is a write up on an issue best covered in a mailing list thread of Januari 2006 (see the links in the text), I repost it because I think it deserves a place on the agenda. == Why? == I was switching back and forward between the model files and the schema.rb -- off course I have