2014-11-24 87 views
0

路線爲什麼確認框不起作用?

resources :listings do 
member do 
    post :leadcreate 
    post :storycreate 
end 

控制器動作

def destroy 
    @listing = Listing.find(params[:id]) 
    @listing.destroy 
    redirect_to 'root_path', :notice => "Listing Successfully Deleted" 
    end 

查看

<%= link_to "Delete", listing_path(@listing), :confirm => "Confirm Deletion", :method => :delete %> 

錯誤

它只是爲「No數據接收「頁面,然後當我刷新並返回到根目錄時,該列表實際上已被刪除。

回答

1

如果使用的是軌道4,你應該把它作爲數據屬性

link_to "Delete", listing_path(@listing), :method => :delete, :data => {:confirm => 'Confirm Deletion'} 

文檔here

相關問題