Rails - Preventing users from contributing to website when there score is too low - callback / obser
- by adam
A User can add a Sentence directly on my website, via twitter or email. To add a sentence they must have a minimum score. If they don't have the minimum score they cant post the sentence and a warning message is either flashed on the website, sent back to them via twitter or email.
So I'm wondering how best to code this check. Im thinking a sentence observer. So far my thoughts are in before_create
score_sufficient()
- score ok = save
- score too low = do not save
In the case of too low i need to return some flag so that the calling code can then fire off teh relevant warning.
What type of flag should I return? False is too ambiguous as that could refer to validation. I could raise an exception but that doesn't sound right or I could return a symbol? Is this even the right approach?
What's the best way to code this?