所以我試圖讓client_side_validations
寶石的工作,當我標籤我的電子郵件領域,我得到這個錯誤:client_side_validations「不能讀取屬性‘用戶[郵件]’未定義」
Uncaught TypeError: Cannot read property 'user[email]' of undefined
這是我的表單輔助函數:
<%= form_for(resource, :as => resource_name, :class => "send-with-ajax", :url => user_registration_path(resource), :validate => true) do |f| %>
<%= f.email_field :email, :id => "form-email", :placeholder => "[email protected]", :input_html => {:autofocus => true}, :validate => true %>
<%= f.submit :label => "Submit", :value => "Sign Me Up!" %>
<div class="ajax-response"><%= devise_error_messages! %></div>
<% end %>
生成此HTML:
<form accept-charset="UTF-8" action="/users" class="new_user" data-validate="true" id="new_user" method="post" novalidate="novalidate">
<input name="utf8" type="hidden" value="✓" />
<input name="authenticity_token" type="hidden" value="9JdqaiushdauhsdioauhdoiuhNLSAVCGrc+PLJAQ=" />
<input data-validate="true" id="form-email" input_html="{:autofocus=>true}" name="user[email]" placeholder="[email protected]" size="30" type="email" />
<input label="Submit" name="commit" type="submit" value="Sign Me Up!" />
<div class="ajax-response"></div>
</form>
編輯1:即使我將表單助手從f.email_field :email
更改爲f.text_field :email
...我仍然收到此錯誤。
不幸的是,它並沒有涵蓋那個特定的問題。當我遇到這個錯誤時,我正在關注這個Railscast。 – marcamillion