Tag Archives: ruby

ruby on rails 验证

一些例子: validates :terms, :acceptance => true validates :password, :confirmation => true validates :username, :exclusion => { :in => %w(admin superuser) } validates :email, :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, :on => :create } validates :age, :inclusion => { :in => 0..9 } validates :first_name, :length => { :maximum => 30 } validates :age, :numericality =>… Read More »