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

  • Home
  • SEARCH
  • 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 9062825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:50:09+00:00 2026-06-16T15:50:09+00:00

I have searched a lot for this issue with no luck… I have a

  • 0

I have searched a lot for this issue with no luck…

I have a model with a before_update method, I can’t replace it with a validator because the actual method checks the existance of many things and update many others. My question is, How can I raise an error if a process from the before_update method fails? Something like:

def update_status
    if !(many verifications and updates)
       self.errors[:base] << "Could not update if ...."
    end
end

With the abobe code I get the update notice from the controller after the page loads, but I want to show the error from the before_update method. How can I show the error to the user?

Thanks a lot!!

  • 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-06-16T15:50:11+00:00Added an answer on June 16, 2026 at 3:50 pm
    def update_status
        if !(many verifications and updates)
           raise "Could not update if ...."
        end
    end
    

    Now do show the error message on the controller you could do something like this:

    begin
      @myObject.update_status
    rescue => ex
      flash[:notice] = ex.message
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched a lot for this issue. But couldn't find the exact answer.
I have searched a lot and tried much but I can not find the
I am new to this and have searched a lot this week. I am
I know this is asked before and I have already searched a lot about
i have searched lot for the similar question and i decided to ask this
I have searched a lot and couldn't found the approach to create the small
I have searched a lot trying to find something for my purpose, however most
I have searched a lot about the difference between Website and WebApplication but didn't
firstly i have searched a lot and all topics seems to be C# :
What is the difference between a listener and handler? I have searched a lot,

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.