Is there a way to filter out links posted in a comment or in a form. The datatype of the column where the field is stored might be text or varchar. I essentially want to strip off any kind of url embedded witin the content.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could try
strip_links. From the Rails docs:There’s also a
strip_tagswhich removes any HTML tags from a string.These functions won’t be available in your model, however; only in your views. As far as I know, there’s no built-in methods to accomplish this from the model. If you need to do it in the view, you could try extending the model with the relevant ActiveView class(es). Otherwise, it should be fairly easy to construct a regular expression to strip the links.