Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
2 total  XML / RSS feed 

sample of dutch validation error messages

//Dutch validation error messages
//Put this at the end of environment.rb

module ActiveRecord
  class Errors
    begin
      @@default_error_messages = {
        :empty => "dient verplicht ingevuld te worden",
        :blank => "dient verplicht ingevuld te worden",
      }
    end
  end
end

Custom Validation in ActiveRecord

// allows adding errors in methods other than validate

  def other_errors=(err)
    write_attribute(:other_errors,Array.new) if !self.other_errors
    self.other_errors[self.other_errors.length] = err
  end
        
  def other_errors
    read_attribute(:other_errors)
  end

  def validate
    if self.other_errors
      self.other_errors.each {|x| errors.add_to_base(x)}
      return
    end
    return if !errors.empty?
  end
« Newer Snippets
Older Snippets »
2 total  XML / RSS feed