Call Montréal, Canada 524-949-6869

Blog

Monday, September 13, 2010

Rails Validations can be any ActiveRecord Model Instance Methods

class Customer

  # first_name: string
  # last_name: string

  validates_presence_of :first_or_last_name, :message => "must be provided"

  def first_or_last_name
    first_name || last_name
  end

end

Developing Ruby on Rails applications and custom Content Management Systems in Montréal. Contact Firsthand.