Ruby on rails 定制设计可恢复的验证错误
我想定制 重置密码令牌不能为空Ruby on rails 定制设计可恢复的验证错误,ruby-on-rails,ruby-on-rails-3,devise,Ruby On Rails,Ruby On Rails 3,Devise,我想定制 重置密码令牌不能为空 如果提交用户/password/edit而不将reset\u password\u令牌作为查询字符串参数,则会发生验证错误。此验证不在designe.en.yml中,我找不到designe的源代码中声明的验证器的位置。有可能吗?我把它从gem中取出,放到config/locales en: errors: messages: not_found: "not found" already_confirmed: "was alrea
如果提交用户/password/edit而不将reset\u password\u令牌作为查询字符串参数,则会发生验证错误。此验证不在designe.en.yml中,我找不到designe的源代码中声明的验证器的位置。有可能吗?我把它从gem中取出,放到
config/locales
en:
errors:
messages:
not_found: "not found"
already_confirmed: "was already confirmed"
not_locked: "was not locked"
devise:
failure:
unauthenticated: 'You need to sign in or sign up before continuing.'
unconfirmed: 'You have to confirm your account before continuing.'
locked: 'Your account is locked.'
invalid: 'Invalid email or password.'
invalid_token: 'Invalid authentication token.'
timeout: 'Your session expired, please sign in again to continue.'
inactive: 'Your account was not activated yet.'
sessions:
signed_in: 'Signed in successfully.'
signed_out: 'Signed out successfully.'
passwords:
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
updated: 'Your password was changed successfully. You are now signed in.'
confirmations:
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
confirmed: 'Your account was successfully confirmed. You are now signed in.'
registrations:
signed_up: 'You have signed up successfully. If enabled, a confirmation was sent to your e-mail.'
updated: 'You updated your account successfully.'
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
unlocks:
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
unlocked: 'Your account was successfully unlocked. You are now signed in.'
mailer:
confirmation_instructions:
subject: 'Confirmation instructions'
reset_password_instructions:
subject: 'Reset password instructions'
unlock_instructions:
subject: 'Unlock Instructions'
重置密码令牌错误应该只是一个标准属性
reset\u password\u token
,其键为blank
,存储在您嵌入设备的模型中。假设您的类名为User,并且您使用的是ActiveRecord,则应该可以:
en:
activerecord:
attributes:
user:
reset_password_token: Password token
errors:
models:
user:
attributes:
reset_password_token:
blank: was not found
应该将“未找到密码令牌”作为错误消息提供给您。这些是Desive中针对控制器错误而不是模型验证的一般错误。谢谢,这正是我需要的!