Tag: Rails3/問い合わせフォーム
class Contact include ActiveModel::Validations include ActiveModel::Conversion extend ActiveModel::Naming attr_accessor :name, :email, :subject, :message validates :name, :presence => true # confirmation?が必要 validates :email, :presence => true, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i } validates :subject, :presence => true validates :message, :presence => true def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end end def persisted? false end end