编辑操作不适用于Rails中的弹出式引导程序模态

时间:2018-12-13 10:17:44

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2 ruby-on-rails-5

我是初学者。我想在引导程序弹出模式上调用编辑操作,并且视图很好,但是编辑操作不起作用。

视图

  <%@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

1 个答案:

答案 0 :(得分:2)

您的路线应定义为

Rails.application.routes.draw do
  resources :leaves      
end

对于Singular Resource,您可以写为resource :leave