使用client_side_validation with devise登录用户

时间:2013-09-26 12:43:31

标签: ruby-on-rails devise client-side-validation

我正在使用带有设计的client_side_validation gem, 有类似question,但它没有帮助我, 为什么我不能关闭certrain字段的验证?

这是我的代码

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :remote => true) do |f| %>
<%= f.email_field :email, :autofocus => true, class: 'login-form-fields span4', placeholder: "email", :validate => false %>
  <%= f.password_field :password, class: 'login-form-fields span4', placeholder: "pass", :validate => {:presence => true} %>
  <div><%= f.submit "Sign in", class: 'login-btn-submit' %></div>
<% end %>

1 个答案:

答案 0 :(得分:0)

您是否更改了Devise的默认身份验证密钥?

config/initializers/devise.rb中将config.authentication_keys =行更改为您想要的任何属性。 IE:config.authentication_keys = [:username]

然后,在您的Devise User / Admin /任何型号中添加:

def email_required?
  false
end

def email_changed?
  false
end

有关详细信息,请参阅this previous question