2014-12-30 24 views
0

目前我有工作設計形式,但現在我試圖用parsley-rails添加一些客戶端驗證。 如何包括的form_for助手3論點,如果我能我使用Ruby on Rails:錯誤的參數數量(設計和香菜欄寶石)

Rails 4.1.8 
ruby 2.1.5p273 

所以這是我的表格只包含2個參數

<%= form_for(resource as: resource_name, url: registration_path(resource_name)) do |f| %> 
     <%= devise_error_messages! %> 

     <div class="field"> 
     <%= f.label :username %><br /> 
     <%= f.text_field :username, autofocus: true %> 
     </div> 

     <div class="field"> 
     <%= f.label :email %><br /> 
     <%= f.email_field :email %> 
     </div> 

     <div class="field"> 
     <%= f.label :password %> 
     <% if @validatable %> 
     <em>(<%= @minimum_password_length %> characters minimum)</em> 
     <% end %><br /> 
     <%= f.password_field :password, autocomplete: "off" %> 
     </div> 

     <div class="field"> 
     <%= f.label :password_confirmation %><br /> 
     <%= f.password_field :password_confirmation, autocomplete: "off" %> 
     </div> 

     <hr> 

     <div> 
     <%= f.label :country_id %> 
     <%= f.select(:country_id, options_from_collection_for_select(Country.all, :id, :name)) %> 
     </div> 

     <br><br> 

     <div class="actions"> 
     <%= f.submit "Sign up" %> 
     </div> 
    <% end %> 

    <%= render "devise/shared/links" %> 

,這是香菜護欄說明: 然後我添加以下內容到我希望驗證的表格上

<%= form_for :user, :html => {:"data-validate" => 'parsley'} do |user| %> 

當我試圖加入這一行我總是得到即使我刪除了錯誤:HTML => {:「數據驗證」 =>「香菜」}線

wrong number of arguments (3 for 2) 

Extracted source (around line #3):  

<h2>Sign up</h2> 
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :validate => true) do |f| %> 
<%= devise_error_messages! %> 
<div class="field"> 
+0

它看起來像你缺少resource'後'一個逗號在'的form_for(資源爲:RESOURCE_NAME ...' – Carpetsmoker

回答

0

我發現如何包括這個。 這是應該的form_for怎麼看起來像

<%= form_for(resource, :html => {:'data-validate' => 'parsley'}, :as => resource_name, :url => registration_path(resource_name)) do |f| %> 
.... 
<% end %> 
相關問題