2013-06-05 67 views
2

我的客戶端驗證不起作用。Ruby On Rails,客戶端驗證,不能與form_tag一起使用

我html.erb:

<%= form_tag what_to_do_file_path, method: :get do %> 
          <%= submit_tag "Delete selected", :commit =>"delete" %> 
          <%= submit_tag "Pictures/Info/Raw Int", :commit =>"pictures" %> 
          <%= submit_tag "File normalize", :commit =>"pictures" %> 

          <%= form_for Group.new, :validate => true do |f| %> 
          <div class="field_label"> 
          <%= f.label :group_name%>: 
          </div> 
          <div class="field"> 
          <%=f.text_field :group_name %> 
          </div> 
          <%end%> 
     <% @files.each do |file| %> 

     <p><td> <%= check_box_tag "files[]", file.id %></td><%= file.file_name %></p> 
     <%=end%> 
<%=end%> 

我的控制器:

class Group< ActiveRecord::Base 
    include ActiveRecord::Validations 
    attr_accessible :group_name 
    validates :group_name,     
            :uniqueness => { :case_sensitive => false} 

end 

我what_to_do行動我趕上文件的ID,我想組,而params [:提交],這意味着我想對此組中的文件執行什麼操作。

文件1,文件2,文件3 我選擇所有這些文件並輸入組名「TRIPPLE」,然後選擇什麼,我想這個團體(無論是文件正常化或任何..) 做(該組的名稱應該驗證,如果這個組已經存在,在what_to_do我想要捕獲文件的ID,PARAMS [提交]和組名稱)

如果我把一個form_for外部form_tag ,但我需要將它放在form_tag中,因爲我想在what_to_do操作中捕獲組的名稱。
我該怎麼做?

回答

1

你爲什麼不使用

form_for :something, url: what_to_do_file_path, method: :get 

它總是鼓勵的form_for使用這個還挺任務