lundi 29 avril 2019

ActionController::UrlGenerationError in Interfaces#index

I am trying to delete my interface,and it said No route matches {:action=>"show", :controller=>"interfaces", :project_id=>#}, missing required keys: [:id].

Because I do not which arguments should be put into <%=link_to '删除', project_interface_path()%>

I have tried many different arguments into a path.

It is my interface_controller.rb file:

def destroy
    @interface = @proeject.interfaces.find(params[:project_id])
    if @interface.destroy
      redirect_to project_interfaces_path
    end
end
  def index
    @interfaces = Interface.all
    @project = Project.find(params[:project_id])

  end
  def new
    @project = Project.find(params[:project_id])
    @interface = Interface.new
  end

  def create
    @project = Project.find(params[:project_id])
    @interface = @project.interfaces.new(interface_params)
    if @interface.save
      redirect_to project_interfaces_path
    else
      render :new
    end
  end
 It is my interface/index.html.erb

 <% @interfaces.each do |interface| %>
      <tr>
        <th scope="row">1</th>
        <td><%=interface.name %></td>
        <td><%=interface.desp %></td>
        <td><%=interface.method_type_id %></td>
        <td><%=interface.request_url %></td>
        <td><%=interface.request_eg %></td>
        <td><%=interface.response_eg %></td>
      </tr>
      <td><%= link_to '删除', project_interface_path(interface),method: :delete, data:{confirm:'确定要删除吗?'}, class: 'badge badge-dark' %></td>

Aucun commentaire:

Enregistrer un commentaire