我有个叫SurveyCategory的modal,有一些content等字段。现在的问题是,我想进入edit页面后,更改后submit,不是@survey_category.update_attribues...
, 我想提交后这个surveycategory不被改变,但是生成一个新的surveycategory。
我现在想到的是创建一个recreate action,把edit form改成
<%= form_for @survey_category, :url => recreate_survey_category_path, remote: true do |f| %>
<%= f.label "Survey category title" %>
<%= f.text_field :title %>
<%= f.fields_for :surveys do |builder| %>
<%= render 'survey_fields', :f => builder %>
<% end %>
<p><%= link_to_add_fields "Add another question", f, :surveys %></p>
<%= f.submit "Submit" %>
<% end %>
route为
resources :survey_categories
match "survey_categories" => "survey_categories#recreate", :as=>"recreate_survey_category", via: :post
但是提交后报错HTTP 404,请大家帮忙看看,谢谢了