,我發現了錯誤:「的ActionController :: ParameterMissing在SitesController#消滅」Rails的帕拉姆沒有發現破壞鏈接
它說:「參數未找到:網站」
顯示視圖:
<%= link_to 'Destroy', @site, method: :delete, data: { confirm: 'Are you sure?' } %>
控制器銷燬行動
def destroy
@site = Site.find(site_params)
if @site.present?
@site.destroy
end
redirect_to "sites#index"
end
private
def site_params
params.require(:site).permit(:user_id, :domain)
end
路線
sites GET /sites(.:format) sites#index
POST /sites(.:format) sites#create
new_site GET /sites/new(.:format) sites#new
edit_site GET /sites/:id/edit(.:format) sites#edit
site GET /sites/:id(.:format) sites#show
PATCH /sites/:id(.:format) sites#update
PUT /sites/:id(.:format) sites#update
DELETE /sites/:id(.:format) sites#destroy
爲什麼這不起作用?
我不想成爲那個人,但是你耙第一? – Alexander