require "rubygems"
require_gem "activerecord"

require 'connect'

class Order < ActiveRecord::Base
  validates_format_of :name, :with => '^images/\w+\.jpg$', :message => '\#{name} is bad, bad'
  def validate
    puts "valider"
  end
  def validate_on_create
    puts "valider à la création"
  end
  def validate_on_update
    puts "valider à la mise à jour"
  end
end

o = Order.find(12)
o.name = "images/bejpg"
p o.valid?
p o.errors
