Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 客户端验证gem在rails 3.2.13中不起作用_Jquery_Ruby On Rails_Validation_Devise_Client Side Validation - Fatal编程技术网

Jquery 客户端验证gem在rails 3.2.13中不起作用

Jquery 客户端验证gem在rails 3.2.13中不起作用,jquery,ruby-on-rails,validation,devise,client-side-validation,Jquery,Ruby On Rails,Validation,Devise,Client Side Validation,我花了相当长的时间试图让客户端验证gem工作,但没有显示文本,表单后没有注入脚本标记。我尝试了Rails生成的标准表单和Desive表单。我已经确保包含rails.validations.js文件,并在gem提供的初始化器中取消对块的注释 这是我的密码: 客户端验证。rb ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| unless html_tag =~ /^<label/ %{<

我花了相当长的时间试图让客户端验证gem工作,但没有显示文本,表单后没有注入脚本标记。我尝试了Rails生成的标准表单和Desive表单。我已经确保包含rails.validations.js文件,并在gem提供的初始化器中取消对块的注释

这是我的密码:

客户端验证。rb

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
标准导轨形式

<%= form_for(@report, :validate => true) do |f| %>
<%= f.hidden_field :url, :value => "http://#{request.host}:#{request.port}#{request.fullpath}" %>

<%= f.label :elements %>
<%= f.text_field :elements %>

<%= f.label :comments %>
<%= f.text_area :comments %>

<%= f.submit "Send", :class => 'btn' %>
<%= form_for(resource, :validate => true, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
  <%= devise_error_messages! %>

  <%= f.label "First name" %>
  <%= f.text_field :first_name %>

  <%= f.label "Last name" %>
  <%= f.text_field :last_name %>

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

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

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

  <%= f.label :privacy_policy, :class => 'checkbox' do %>
  <%= f.check_box :privacy_policy %>I agree to the <%= link_to "Privacy policy", privacy_path %><% end %>

  <%= f.submit "Sign up", :class => 'btn' %>
<% end %>
true)do | f |%>
“http://{request.host}:{request.port}{request.fullpath}”%>
'btn'>
设计表单

<%= form_for(@report, :validate => true) do |f| %>
<%= f.hidden_field :url, :value => "http://#{request.host}:#{request.port}#{request.fullpath}" %>

<%= f.label :elements %>
<%= f.text_field :elements %>

<%= f.label :comments %>
<%= f.text_area :comments %>

<%= f.submit "Send", :class => 'btn' %>
<%= form_for(resource, :validate => true, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
  <%= devise_error_messages! %>

  <%= f.label "First name" %>
  <%= f.text_field :first_name %>

  <%= f.label "Last name" %>
  <%= f.text_field :last_name %>

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

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

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

  <%= f.label :privacy_policy, :class => 'checkbox' do %>
  <%= f.check_box :privacy_policy %>I agree to the <%= link_to "Privacy policy", privacy_path %><% end %>

  <%= f.submit "Sign up", :class => 'btn' %>
<% end %>
true,:as=>resource_name,:url=>registration_path(resource_name))do|f|%>
“复选框”do%>
我同意这个建议
'btn'>
我真的不知道下一步能做什么。我需要引用不同版本的gem吗?我如何检查gem是否实际运行

我目前正在使用Rails 3.2.13

我在javascript控制台中没有收到任何错误

如果你想查看相关文件,请告诉我


非常感谢您的指点

请在您的GEM文件中尝试以下操作:

gem 'client_side_validations`, :github => 'bcardarella/client_side_validations', :branch => '3-2-stable'

非常感谢!原来我也需要重新启动rails服务器。你是个明星!我现在遇到的问题是,客户端验证只有在我使用Desive提交表单时才会触发。当我翻阅它们时,它们不会触发,知道为什么吗?很抱歉,我没有使用Desive,所以我不确定你遇到了什么