I have a discussion board, and users can post comments on the board. But to cut down on spam, I am looking for a way to replace any URLs or Email addresses the users put in the text area with something like 'forbidden'. or even just removing them entirely.
I don't really have a clue where to start, so even something as a direction would help greatly. I was thinking of using Regex somehow, or I thought I recalled there's something in Rails already that .restricted or .constrained different things in a text area.
preguntado el 01 de febrero de 12 a las 14:02
You should use ActiveRecord callbacks to check the comments before they're saved in the DB. Look aquí for examples (like
before_save to replace), and use Regex to replace the forbidden content.