Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

I18n::InvalidPluralizationData in Registrations#new and Devise #422

Closed
ulugbekov opened this Issue Oct 29, 2012 · 3 comments

Comments

Projects
None yet
2 participants

I am using English and Russian in my app.

As soon as I add validate:true option to devise form, it gives this error:

translation data {:one=>"is too short (minimum is 1 character)", :other=>"is too short (minimum is %{count} characters)"} can not be used with :count => 6 for english, but for russian it works.

If I remove validate option it works for both languages. That's why I think it is related to client_side_validations

<%= form_for(resource, :validate => true , :as => resource_name, :url => registration_path(resource_name) ,:html => { :id => 'user_new' }) do |f| %>

<%= f.label :email %> <%= f.email_field :email, :validate => {:presence => true} %>
<%= f.label :password %> <%= f.password_field :password, :validate => true %>
<%= f.label :password_confirmation %> <%= f.password_field :password_confirmation, :validate => true %>
<%= f.submit "Sign up" %> <%= link_to "Sign in", new_session_path(resource_name), :class=>"signinor" %>

From Devise's source code upon removing:

validates_length_of :password, :within => password_length, :allow_blank => true

Everything is working fine.

I think I am not sure your source code:

self.class::MESSAGES.each do |option, message_type|
if count = options[option]
options[:message] = options[message_type] if options[message_type].present?
options.delete(:message) if options[:message].nil?
hash[:messages][option] = model.errors.generate_message(attribute, message_type, options.merge(:count => count))
hash[option] = count
end
end

somehow affecting it.

Contributor

bcardarella commented Nov 20, 2012

@ulugbekov I'll try to look at this one this week. Most of the time when dealing with Devise the gem does some crazy stuff on the validations behind the scenes that doesn't always make sense for ClientSideValidations. I'll let you know what I find.

Contributor

bcardarella commented Nov 25, 2012

I am unable to reproduce the issue. I have built an example app using ClientSideValidations and Decise: https://github.com/dockyard/client_side_validations-devise_example

Please use it as a guide, let me know if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment