Reformat attribute before saving and return an error if needed
I'm making a web-app in RoR
I have a model with YouTube video ID so I can use it to embed videos to the web-page.
It works well but I want to make it easier for admins to add videos, and I've already found out how to parse the video's ID from YouTube's URL, but now I thing about where to add it.
I want to notify the user that he have entered the wrong data like the validation does, but if I add some parse_video_id model method or add a before_save hook, how can I add an error to the object so I can then tell about it to the user?
You add errors with: