对我的编辑操作如果记录不存在,我永远不会找到没有找到的记录。我做错了什么。未找到Rails 4.0记录
这里是我的编辑操作
class OffersController < ApplicationController
rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
def show
@offer = Offer.find(params[:id])
end
def edit
@offer = Offer.find_by(edit_hash: params[:edit_hash])
@country = Country.find_by(name: @offer.country)
@states = State.find(:all, :conditions => { country_id: @country })
end
private
def record_not_found
render text: "404 Not Found", status: 404
end
end
我总是得到未定义的方法'国家”的零:NilClass我的历克西斯特编辑记录。
另外,我提出了未在我的show动作中找到的记录,但我想使用我在公用文件夹中的404.html页面。我怎样才能使用这个文件?
在此先感谢
您是否从控制台运行'rake db:migrate'来填充数据库? –