Heroku 上的客户端验证

发布于 2024-11-16 23:23:57 字数 1587 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你好,陌生人 2024-11-23 23:23:57

我发现了这个问题。我没有在客户端验证用户名的格式,这导致了此错误。感谢您的帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文