Jack R-G
Jack R-G

Reputation: 1906

Rails Undefined Constant: ActiveRecord::RecordNotFound

I have the following code in my Application Controller:

class ApplicationController < ActionController::Base
  protect_from_forgery
  rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
  private
  def record_not_found
    render :text => "404 Not Found", :status => 404
  end
end

When I run it (actually I run rake db:migrate) I get the error uninitialized constant ActiveRecord::RecordNotFound. This seems too simple -- HELP!

Upvotes: 3

Views: 2137

Answers (1)

Jack R-G
Jack R-G

Reputation: 1906

It needed require 'active_record/errors', which I didn't see on any of the examples I found when I googled.

Upvotes: 8

Related Questions