Tag Archives: 404

捕获 ActiveRecord::RecordNotFound 输出 404 页面

class ApplicationController < ActionController::Base protect_from_forgery with: :exception rescue_from ActiveRecord::RecordNotFound, with: :render_404 protected def render_404 render(file: “#{Rails.root}/public/404.html”, :layout => false, :status => 404) end end

Posted in ruby on rails | Tagged , , | Leave a comment