Mik*_*ike 6 validation customvalidator devise ruby-on-rails-3
据我所知,设计只对电子邮件和密码进行验证,可以在初始化程序devise.rb中重新配置:
# ==> Configuration for :validatable
# Range for password length. Default is 6..128.
# config.password_length = 6..128
# Regex to use to validate the email address
# config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
Run Code Online (Sandbox Code Playgroud)
如何添加自定义字段的验证,已添加到devise_invitable的邀请表单中?
例如,我需要验证表单中的first_和last_名称:
= simple_form_for resource, :as => resource_name, :url => invitation_path(resource_name) do |f|
= f.input :first_name
= f.input :last_name
= f.input :email
= f.button :submit
Run Code Online (Sandbox Code Playgroud)
提前致谢!
| 归档时间: |
|
| 查看次数: |
1365 次 |
| 最近记录: |