link_to无法正常工作并且找不到页面只允许获取和发布请求

时间:2014-10-07 06:46:55

标签: ruby-on-rails ruby

My route.rb:
------------

  *resources :accounts, :path => "expos" do
    resources :shows, :path => "events" do
    resources :show_sessions, :path => "session"
    end
end*

<% @events.each do |e| %>
<%= link_to '<i class=icon-trash></i>'.html_safe, account_show_path(@context.id, e), :confirm => 'Are you sure?', :method => :delete %>
    <% end %>

Rake Routes:

    account_shows GET    /expos/:account_id/events(.:format)          {:action=>"index", :controller=>"shows"}
                  POST   /expos/:account_id/events(.:format)          {:action=>"create", :controller=>"shows"}
 new_account_show GET    /expos/:account_id/events/new(.:format)      {:action=>"new", :controller=>"shows"}
edit_account_show GET    /expos/:account_id/events/:id/edit(.:format) {:action=>"edit", :controller=>"shows"}
     account_show GET    /expos/:account_id/events/:id(.:format)      {:action=>"show", :controller=>"shows"}
                  PUT    /expos/:account_id/events/:id(.:format)      {:action=>"update", :controller=>"shows"}
                  DELETE /expos/:account_id/events/:id(.:format)      {:action=>"destroy", :controller=>"shows"}

我有删除路线。但我得到“只允许获取和发布请求”。请帮助任何人为什么我会收到错误。

1 个答案:

答案 0 :(得分:-1)

尝试将其更改为此内容;

<% @events.each do |e| %>
      <%= link_to '<i class=icon-trash></i>'.html_safe, account_show_path(@context, @event), :confirm => 'Are you sure?', :method => :delete %>
<% end %>

确保标题中包含以下内容;

<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
      <%= csrf_meta_tags %>