简体   繁体   中英

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

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

I have delete route. But i am getting "Only get and post requests are allowed". Please help anybody why i am getting error.

Try changing it to this;

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

Make sure you have the following in your header;

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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