我是初学者。我想在引导程序弹出模式上调用编辑操作,并且视图很好,但是编辑操作不起作用。
视图
<%@leaves.each do |leave| %>
<td><a href="#" data-toggle="modal" data-target="#myModal-<%= leave.id %>"></td>
<div class="modal fade" id="myModal-<%= leave.id %>" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
</h4>
</div>
<div class="modal-body">
<%= form_for(@leave, url: leave_path) do |f| %>
<%=f.text_field :rejected_reason%>
<%=f.submit'update'%>
<% end -%>
</div>
<div class="modal-footer ">
<%=link_to 'Reject',reject_leave_path(:id=>leave.id), method: :patch,class: "btn btn-danger btn-sm "%>
</div>
</td>
</tr>
<% end %>
路线
Rails.application.routes.draw do
resources :leave
end
答案 0 :(得分:2)
您的路线应定义为
Rails.application.routes.draw do
resources :leaves
end
对于Singular Resource,您可以写为resource :leave