0

whenever I do

        rescue Exception => e
        flash[:error] = e.message

the e.message will always contain the "Validation error:" string and the Object

Example:

Validation failed: Price "message:", Price "message"

How do I tell rails that I just want the message? and not the other parts of the validation error to be displayed?

1 Answer 1

1

You can get the data you want from the #errors attribute of the model you were trying to save. There could potentially be multiple validation errors (not just one).

See http://api.rubyonrails.org/classes/ActiveModel/Errors.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.