没有路线匹配[删除]

时间:2013-10-08 21:49:19

标签: ruby-on-rails ruby gem

我不知道我的应用程序发生了什么。我有一些控制器工作正常,但这不是。

我的sylabus_controller.rb

   # encoding: utf-8
    module Admin
      class SylabusController < BaseController

def destroy
      @sylabu = @topic.sylabus.find(params[:sylabus])
      @sylabu.destroy
     redirect_to  admin_course_topic_sylabu_path(@course, @topic), notice: 'Sylabus deleted'

    end

我的/views/admin/sylabus/index.html.rb

<% @sylabu.each do |syla| %>
            <tr>
                <td><%= syla.mupet_code %></td>
                <td><%= syla.name %></td>

              <td style="width:155px">
         <%= link_to '<i class="icon-pencil"></i>'.html_safe, edit_admin_course_topic_sylabus_path(@course,
                                                                                                        @topic,
                                                                                                        syla),
                            class: 'btn' %>
                    <%= link_to '<i class="icon-trash icon-white"></i>'.html_safe, [:admin, @course, @topic, syla], class: 'btn btn-danger', method: :delete, data: { confirm: 'Are you sure?' } %>

                <%= link_to '<i class="icon-eye-open"></i>'.html_safe, [:admin, @course, @topic, syla],
                            class: 'btn' %>

              </td>
            </tr>
            <% end %>

目标网络在按钮删除是localhost:3000 / admin / courses / 1 / topics / 2 / sylabus.8并带有以下错误消息

Routing Error

No route matches [DELETE] "/admin/courses/1/topics/2/sylabus.8"
Try running rake routes for more information on available routes.

如果我从我的控制台执行rake路线

                          POST   /admin/courses/:course_id/topics/:topic_id/sylabus(.:format)                             admin/sylabus#create
 new_admin_course_topic_sylabu GET    /admin/courses/:course_id/topics/:topic_id/sylabus/new(.:format)                         admin/sylabus#new
edit_admin_course_topic_sylabu GET    /admin/courses/:course_id/topics/:topic_id/sylabus/:id/edit(.:format)                    admin/sylabus#edit
     admin_course_topic_sylabu GET    /admin/courses/:course_id/topics/:topic_id/sylabus/:id(.:format)                         admin/sylabus#show
                               PUT    /admin/courses/:course_id/topics/:topic_id/sylabus/:id(.:format)                         admin/sylabus#update
                               DELETE /admin/courses/:course_id/topics/:topic_id/sylabus/:id(.:format)                         admin/sylabus#destroy

真诚地,我不知道错误即将发生,因为它是来自其他控制器的复制和粘贴功能完美。

非常感谢你的回答。

度过美好的一天

1 个答案:

答案 0 :(得分:1)

通过.8后缀,它看起来像是使用index路径而不是delete路径。尝试明确

<%= link_to 'blah'.html_safe, admin_course_topic_sylabus_path(:admin, @course, @topic, syla), method: :delete %>