Rails 验证 - :无选项
Rails Validation - :without option
我正在尝试(并且惨败)将带有 omniauth 的设计整合到我的 Rails 4 应用程序中。
我目前的工作是让本教程中概述的系统正常工作。 http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/
我目前遇到的问题是验证错误 - 导致服务器无法启动。
我已将此验证包含在我的用户模型中:
validates_format_of :email, :without => TEMP_EMAIL_REGEX, on: :update
当我尝试启动服务器时,出现此错误:
Exiting
/Users/.rvm/gems/ruby-2.2.2/gems/activemodel-4.2.4/lib/active_model/validations/format.rb:44:in `check_options_validity': A regular expression or a proc or lambda must be supplied as :without (ArgumentError)
from /Users/.rvm/gems/ruby-2.2.2/gems/activemodel-4.2.4/lib/active_model/validations/format.rb:21:in `check_validity!'
当我查看文档时,指导说明说:
:without - Regular expression that if the attribute does not match will result in a successful validation. This can be provided as a proc or lambda returning regular expression which will be called at runtime.
http://apidock.com/rails/ActiveModel/Validations/HelperMethods/validates_format_of
我不知道这条注释是什么意思(我不明白 API 文档中的任何内容 - 它的复杂程度远超我的理解)。
任何人都可以看到此验证中的错误吗?
应该是
validates_format_of :email, :without => /TEMP_EMAIL_REGEX/, on: :update
你错过了正则表达式 //
根据文档
我正在尝试(并且惨败)将带有 omniauth 的设计整合到我的 Rails 4 应用程序中。
我目前的工作是让本教程中概述的系统正常工作。 http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/
我目前遇到的问题是验证错误 - 导致服务器无法启动。
我已将此验证包含在我的用户模型中:
validates_format_of :email, :without => TEMP_EMAIL_REGEX, on: :update
当我尝试启动服务器时,出现此错误:
Exiting
/Users/.rvm/gems/ruby-2.2.2/gems/activemodel-4.2.4/lib/active_model/validations/format.rb:44:in `check_options_validity': A regular expression or a proc or lambda must be supplied as :without (ArgumentError)
from /Users/.rvm/gems/ruby-2.2.2/gems/activemodel-4.2.4/lib/active_model/validations/format.rb:21:in `check_validity!'
当我查看文档时,指导说明说:
:without - Regular expression that if the attribute does not match will result in a successful validation. This can be provided as a proc or lambda returning regular expression which will be called at runtime.
http://apidock.com/rails/ActiveModel/Validations/HelperMethods/validates_format_of
我不知道这条注释是什么意思(我不明白 API 文档中的任何内容 - 它的复杂程度远超我的理解)。
任何人都可以看到此验证中的错误吗?
应该是
validates_format_of :email, :without => /TEMP_EMAIL_REGEX/, on: :update
你错过了正则表达式 //
根据文档