Skip to content

Instantly share code, notes, and snippets.

View sur's full-sized avatar

Sur Max sur

View GitHub Profile
@sur
sur / formats.rb
Created August 23, 2012 05:33
validate formats
require 'open-uri'
class Some < ActiveRecord::Base
# validates urls
validates :url, :presence => true, :format => /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix,
:uniqueness => true
# validates email
@wrs
wrs / app_config.rb
Created July 5, 2010 21:54
Simple Rails app configuration class
# Simple configuration system
#
# The configuration is represented as a tree of keys. Examples:
#
# AppConfig['key']
# AppConfig['key','subkey']
# AppConfig['key.subkey']
#
# An optional default value can be specified:
#