每次我刪除或銷燬的產品是贈品給我這個錯誤在我的控制檯:找不到「對象」與ID = ActiveRecord的:: RecordNotFound
ActiveRecord::RecordNotFound (Couldn't find Product with ID=4):
app/controllers/products_controller.rb:16:in `show'
,並在頁面上它給:
ActiveRecord::RecordNotFound in ProductsController#show
Couldn't find Product with ID=4
對我的產品控制器我只是普通支架:
def show
@product = Product.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @product }
end
end
def destroy
@product = current_user.products.find(params[:id]) #current user deletes own
@product.destroy
respond_to do |format|
format.html { redirect_to(products_url) }
format.xml { head :ok }
end
end
我用Rails Jquery的UJS和RAI ls-jquery並在我的應用程序佈局中有csrf_meta_tag
。我注意到的是,當我點擊銷燬鏈接並彈出窗口並說「你確定」時,我點擊確定按鈕,它會因爲一些奇怪的原因而閃爍TWICE,直到我安裝了Jquery纔會這樣做。我該如何解決?
編輯 - 答:
重新安裝導軌jQuery的UJS>https://github.com/rails/jquery-ujs
你必須保持兩個文件jquery.min.js
和jquery.js
。我刪除了jquery.min.js,因爲我認爲這是一個最小化的版本,但顯然不是,這裏有我的所有文件從jQuery的UJS:
jquery.js
jquery.min.js
jquery_ujs.js
rails.js # i had to install this manually from the link (or zip file)
jquery-ui # i wanted the user interface too
你可以發佈型號代碼嗎?如果它很大,你可以在Github上添加一個鏈接。同樣可以看到application.js。 – Midwire
它的完成,我的application.js是空的,我還沒有使用它。 – LearningRoR
您是否最近從現有應用程序升級到3.1 rc?如果是這樣,我會確保你已經卸載了所有舊的prototype.js文件。 –