Reputation: 16339
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?
Upvotes: 0
Views: 1720
Reputation: 12391
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
Upvotes: 1