0

Validates_format_of : api.rubyonrails.org 上提供的电子邮件示例正在引发错误。

class Person < ActiveRecord::Base validates_format_of :email, :with => %r\A([^@\s]+)@((?:[-a-z0-9]+.)+[az]{2 ,})\Z/, :on => :create end

验证 :email, :format => { :with => %r\A([^@\s]+)@((?:[-a-z0-9]+.)+[az]{2,} )\Z/, :on => :create }

目前我正在使用 rails 3.2.8 版本。

在加载获取错误为“语法错误,意外']',期待keyword_end”

4

1 回答 1

2

validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+.)+[az]{2,})\Z/i, :on => :创建

于 2012-10-10T13:58:17.397 回答