Search code examples
ruby-on-railsdeviseclient-side-validation

Client side validations with Devise


I am trying to use the client_side_validations gem with Devise to validate devise registrations form.

Validations work fine with everything else just not the Devise generated form.

I added the relevant :validate => true but the validations only work when I hit submit not on tab like they do on every other form.

<h2>Sign up</h2>
<hr />

<%= form_for(resource, :validate => true, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
  <%= devise_error_messages! %>

  <div><%= f.label :username %>
  <%= f.text_field :username %></div>

  <div><%= f.label :email %>
  <%= f.email_field :email %></div>

  <div><%= f.label :password %>
  <%= f.password_field :password %></div>

  <div><%= f.label :password_confirmation %>
  <%= f.password_field :password_confirmation %></div>

  <br />

  <div><%= f.submit "Sign up", :class => "btn btn-primary btn-large" %></div>
<% end %>

<%= render "links" %>

Solution

  • Argc, argv! I am using Rails 3.2.1, the latest release of the gem is incompatible with 3.2 hence the nightmare. Using 3.2.0.beta.2 fixes the problems. Thanks!