在这里,我使用具有单一模型 user.rb 的设备注册和登录表单的错误消息。如何更改字段电子邮件的错误消息和不同表单的密码?在 user.rb 我使用:
validates_presence_of :full_name
validates_presence_of :email, :message => "enter email"
validates_confirmation_of :password
validates_presence_of :password, :message=> "enter password"
在注册表单中:
= form_for(resource, :validate => true, :as => resource_name, :url => registration_path(resource_name)) do |f|
%ul
%li
= f.label :full_name
= f.text_field :full_name
%li
= f.label :email
= f.email_field :email
%li
= f.label :password
= f.password_field :password
%li
= f.label :password_confirmation
= f.password_field :password_confirmation
%li
= f.label :zip
= f.text_field :zip
= f.submit "Sign up", :class=> "btn btn-primary"
登录表格:
= form_for(resource, :validate => true, :as => resource_name, :url => session_path(resource_name)) do |f|
%ul
%li
= f.label :email
= f.email_field :email
%li
= f.label :password
= f.password_field :password
- if devise_mapping.rememberable?
%li
= f.check_box :remember_me
= f.label :remember_me
%div
= f.submit "Log in", :class=> "btn btn-primary mt10 ml60"
如何更改上述登录表单的消息?