每次我删除或销毁的产品是赠品给我这个错误在我的控制台:找不到“对象”与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文件。 –