Heroku 上的客户端验证
我正在使用 https://github.com/bcardarella/client_side_validations 来验证我的注册表单。
我正在以这种形式验证用户名和电子邮件的唯一性:
validates_uniqueness_of :username, :email, :case_sensitive => false
唯一性的数据库验证在我的本地计算机上进行得很好。但是当我在 Heroku 上尝试它们时,它们不起作用。
编辑:
这是注册表单(我正在使用设计):
<%= form_for @user, :as => :user, :validate => true, :url => user_registration_path do |f| %>
<div><%= f.label :name, :class => "signupin-label span-2" %><%= f.text_field :name, :class => "signupin-field last", :autocomplete => "off"%></div>
<div><%= f.label :username, :class => "signupin-label span-2" %><%= f.text_field :username, :class => "signupin-field last", :autocomplete => "off" %></div>
<div><%= f.label :email, :class => "signupin-label span-2" %><%= f.text_field :email, :class => "signupin-field last", :autocomplete => "off" %></div>
<div><%= f.label :password, :class => "signupin-label span-2" %><%= f.password_field :password, :class => "signupin-field last", :autocomplete => "off" %></div>
<div class="signupin-bl"><%= f.submit "Sign up", :id => "signUpButton" %></div>
<% end %>
我收到以下错误:
rails.validations.js:154
Uncaught TypeError: Object (?-mix:^(a-zA-Z*?| ([a-zA-Z0-9]+_?)*)$) 没有方法 'test'
有人可以指导吗?
谢谢!
I am using https://github.com/bcardarella/client_side_validations to validate my sign up form.
I am validating the uniqueness of username and email in that form:
validates_uniqueness_of :username, :email, :case_sensitive => false
The database validations for uniqueness are taking place fine on my local machine. But when I try them on Heroku, they do not work.
Edit:
Here is the sign up form (I am using devise):
<%= form_for @user, :as => :user, :validate => true, :url => user_registration_path do |f| %>
<div><%= f.label :name, :class => "signupin-label span-2" %><%= f.text_field :name, :class => "signupin-field last", :autocomplete => "off"%></div>
<div><%= f.label :username, :class => "signupin-label span-2" %><%= f.text_field :username, :class => "signupin-field last", :autocomplete => "off" %></div>
<div><%= f.label :email, :class => "signupin-label span-2" %><%= f.text_field :email, :class => "signupin-field last", :autocomplete => "off" %></div>
<div><%= f.label :password, :class => "signupin-label span-2" %><%= f.password_field :password, :class => "signupin-field last", :autocomplete => "off" %></div>
<div class="signupin-bl"><%= f.submit "Sign up", :id => "signUpButton" %></div>
<% end %>
I am getting following error:
rails.validations.js:154
Uncaught TypeError: Object (?-mix:^(a-zA-Z*?|([a-zA-Z0-9]+_?)*)$) has no method 'test'
Can someone please guide?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了这个问题。我没有在客户端验证用户名的格式,这导致了此错误。感谢您的帮助。
I found the issue. I was not validating the format of username on the client side and that was causing this error. Thanks for your help.