search for: svalidator_#

Displaying 1 result from an estimated 1 matches for "svalidator_#".

2011 Jan 08
4
Help How to create DSL for conditional validations
...e than 3 addresses". end end end This way I want in new and edit form I can ask user to click :bypass_validation attribute and I will bypass this validation. I tried to create def valid_with_cond(name, &block) attr_accessor name define_method "svalidator_#{name}" do |*arg| if send name yield *arg end end end But after trying it in Class Person < ActibeRecord::Base valid_with_cond :test do if self.addresses > 3 errors[:base] << "Can not have more than 3 addresses". end end end But...