Search code examples
ruby-on-rails-3.1formtasticclient-side-validation

ClientSideValidations.formBuilders[settings.type] is undefined


I'm trying to use client_side_validations gem, but have some problems. First, I have in my Gemfile

 gem 'client_side_validations', :git => 'https://github.com/bcardarella/client_side_validations.git'

and I after bundle install I see

Using client_side_validations (3.2.0.beta.2) from https://github.com/bcardarella/client_side_validations.git (at master)

but I don't see this gem in gem list....This is first problem. Second, and more important, validations do not work. I have an error in firebug console

ClientSideValidations.formBuilders[settings.type] is undefined

and no validations happen. I'm using rails 3.2.1, formtastic 2.0.2 and here is my client_side_validations.rb file

  # ClientSideValidations Initializer

      # Uncomment the following block if you want each input field to have the validation messages attached.
         # ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
    #   unless html_tag =~ /^<label/
            #     %{<div class="field_with_errors">#{html_tag}<label for="#{instance.send(:tag_id)}" class="message">#{instance.error_message.first}</label></div>}.html_safe
         #   else
        #     %{<div class="field_with_errors">#{html_tag}</div>}.html_safe
       #   end
        # end

Any help will be appriciated.....


Solution

  • The problem was that since Formtastic 2.0 version for correct working client_side_validations gem you need to install client_side_validations-formtastic gem.