我有一個創建頁面模板的應用程序。用戶帳戶中有許多頁面(用戶模板)。我收到以下錯誤,當我點擊我的刪除按鈕:爲頁面控制器創建刪除路由
瀏覽器:
Routing Error
No route matches [DELETE] "/pages/1"
HTML:
<%= link_to 'Delete', page_path(page), :method => :delete,
:confirm => "Are you sure you want to delete?",
:remote => true,
class: 'btn btn-table-action btn-danger' %>
控制器:
def destroy
@page = Page.find(params[:attributeID])
@page.destroy
render :index
end
條
路線:
pages GET /pages(.:format) pages#index
POST /pages(.:format) pages#create
edit_page GET /pages/:id/edit(.:format) pages#edit
page GET /pages/:id(.:format) pages#show
PUT /pages/:id(.:format) pages#update
UPDATE:
的routes.rb:
resources :pages, only: [:index, :show, :create, :edit, :update] do
resource :optin_integration, only: [:edit, :update]
end
我在哪裏開始創建一個刪除的方法,使我的刪除按鈕的功能Rails的?
你可以發佈你的'config/routes.rb'文件嗎? – dasnixon
我在routes.rb文件中包含':pages' – andy4thehuynh
是的,然後做什麼@screenmutt建議並添加:摧毀''只有' – dasnixon