首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ActionController::Interfaces#index中的UrlGenerationError

ActionController::Interfaces#index中的UrlGenerationError
EN

Stack Overflow用户
提问于 2019-04-29 18:24:35
回答 1查看 213关注 0票数 0

我试图删除我的界面,上面写着

没有路由匹配{:action=>"show“、:controller=>”接口“、:project_id=>#},缺少必需的键::id。

因为我不知道哪些参数应该放在<%=link_to '删除', project_interface_path()%>

我尝试了许多不同的论点。

interface_controller.rb

代码语言:javascript
复制
def destroy
  @interface = @project.interfaces.find(params[:project_id])
  redirect_to project_interfaces_path if @interface.destroy
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

接口/index.html.erb

代码语言:javascript
复制
<% @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>

这是我的路线文件:

代码语言:javascript
复制
Rails.application.routes.draw do

  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  root "method_types#index"

  resources :method_types
  resources :field_types
  resources :projects do
    resources :interfaces
  end

end
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-29 18:50:59

试试这个:

代码语言:javascript
复制
<%= link_to '删除', project_interface_path(@project.id, interface.id),method: :delete, data:{confirm:'确定要删除吗?'}, class: 'badge badge-dark' %></td>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55908896

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档