我正在尝试使用Judge gem进行客户端验证,但验证无效。
在我使用的宝石文件中
# Forms
gem 'simple_form', '3.0.2'
#Client side validations
gem 'judge'
我有simlpe_form gem,我知道我需要使用插件用于简单形式的判断,但我试图在普通的form_for中使用,但它也不能使用它。
我的模型看起来像
class User < ActiveRecord::Base
paginates_per 10
validates :name , presence: true, length: { maximum: 200 }
在我看来
- title 'User Registration'
.vcentered
.signup-box
- if @user.authorizations.any?
%h1 We just need a little more information...
- else
%h1 We just need a little bit of information...
= form_for @user,:builder => Judge::FormBuilder, url: user_registration_path, html: { class: 'new-user form-default' } do |f|
- if @user.name.blank?
= f.text_field :name, class: class_with_errors(@user, :name),
title: title_with_errors(@user, :name),
placeholder: 'Full Name',
:validate => true
我已经按照gem的github页面上给出的所有配置stps。 请建议问题的解决方案或我如何找到问题的原因。 在我加载页面浏览器的客户端验证中说(在中间位置,我忘记了它的名称)
localhost:3000上的页面说:PAge不能为空。知道它为什么会这样工作吗?
答案 0 :(得分:0)
rails generate judge:install path / to / your / js / dir
然后在你的route.rb
mount Judge :: Engine =&gt; &#39; /法官&#39;