繁体   English   中英

link_to无法正常工作并找不到页面仅允许get和post请求

[英]link_to not working and getting Page not found Only get and post requests are allowed

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

耙道:

    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"}

我有删除路线。 但是我得到“只允许get和post请求”。 请帮助任何人我为什么会出错。

尝试将其更改为此;

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM