報錯信息如下
ArgumentError: The provided regular expression is using multiline anchors (^ or $), which may present a security risk. Did you mean to use \A and \z, or forgot to add the :multiline => true option?
報錯原因如下
我寫了個郵箱驗證,正則中用到了標誌一行開頭結尾 (^) 和 ($)
validates :email, :presence => true, :uniqueness => true, :format=> {:with => /^\w+@\w+\.\w+$/},:length => {:maximum => 40}
解決方法如下
validates :email, :presence => true, :uniqueness => true, :format=> {:with => /^\w+@\w+\.\w+$/,:multiline => true},:length => {:maximum => 40}