class PostsController < ApplicationController rescue_from ActiveRecord::RecordNotFound, :with => :deny_access ... def show @post = Post.find_by_id(params[:id]) raise ActiveRecord::RecordNotFound if @post.nil? #illegal access
That can be rewritten in a single line, since AR::Base.find precisely raises ActiveRecord::RecordNotFound if the record is not found:
@post = Post.find(params[:id])
def deny_access respond_to do |format| format.html end end
but the exception is not raised ... did I miss something ?
It should work, please debug this a little more.
-- fxn