validates_format_of:电子邮件抛出错误

时间:2012-10-10 13:54:19

标签: ruby-on-rails-3

Validate_format_of:api.rubyonrails.org上提供的电子邮件示例正在抛出错误。

class Person<的ActiveRecord :: Base的   validates_format_of:email,:with => %r \ A([^ @ \ s] +)@((?:[ - a-z0-9] +。)+ [a-z] {2,})\ Z /,:on => :创建 端

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

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

加载时收到错误 “语法错误,意外''',期待keyword_end”

1 个答案:

答案 0 :(得分:2)

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