Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7041789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:05:21+00:00 2026-05-28T02:05:21+00:00

I handle RecordNotFound error in my application_controller.rb as follow: rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found

  • 0

I handle RecordNotFound error in my application_controller.rb as follow:

  rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found

  private 

   def record_not_found
     flash[:error] = "Oops, we cannot find this record"
     redirect_to :back
   end

But I would like to get more information, such as class/table name of which record was not found.
How should I go about it?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:05:21+00:00Added an answer on May 28, 2026 at 2:05 am

    Say for example,

    begin
    @user = User.find(params[:id])
    rescue ActiveRecord::RecordNotFound
      flash[:notice] = "#No such record in User for id :: {params[:id]} on #{action_name}"
    end
    

    UPDATE

    flash[:notice] = t('flash.recordnotfound',:class_name => self.class.name, :column_name => params[:id], :action_name => action_name)
    

    Now in your config/locales/en.yml (this would help translate, refer to i18n here)

    flash:
      recordnotfound:  "Sorry, no record od %{column_name} in class %{class_name} was found on you action %{action_name}"
    

    If you do not want to use locales just put up this information in flash[:notice] itself.

    More dynamic ?

    Write a function and use the same flash [:notice] there. Wont hurt at all.

    want more data ?

    Heres a quick solution, i always <%= params%> in my views to know easily whats going and whats coming. You can then open your rails console and play along with different actions and so on.

    user = User.new
    user.save
    user.errors.messages
    

    All of this is good enough data, i think.

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I handle commands inside a RoutedCommand class that implements RoutedUICommand. This would help me
I'm trying to handle an exception error caused when the wrong user name and
I have a page model that I want to find by a handle that
messagebox (handle, 'do you really want to exit?', 'are you sure?', 1); in this
To handle viewExpiredException in JSF, I coded <error-page> <exception-type>javax.faces.application.ViewExpiredException</exception-type> <location>/error.html</location> </error-page> <session-config> <session-timeout>1</session-timeout> </session-config>
How do I handle multiple clients in Java without getting connection refused error?
I have to handle a form generated by a third part. This form provides
No Activity found to handle Intent error? How it will resolve. Preference customPref =
This following code handle button click event. When the user click first time it
I handle a website which is designed in GWT and I want to check

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.