I am trying to redirect if the record is not found. The page is not redirect and I get the error record not found.
My controller:
def index @link = Link.
You are on the right track, just capture the RecordNotFound exception:
RecordNotFound
def index @link = Link.find(params[:id]) # should render index.html.erb by default rescue ActiveRecord::RecordNotFound redirect_to(root_url, :notice => 'Record not found') end