All threads / Best way to create a report/spam button?

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Best way to create a report/spam button?

Ryan Carter asked in Rails

Just looking for ideas on the best way to create a report or spam button/link on posts and comments. And do you typically have that notification sent to an in program inbox to an admin email, etc.

Thanks,
Ryan

@ryan it is pretty straight-forward. Typically you count how many times that button is pushed (if it is user facing) and then start applying rules based on that count to auto-remove and what not. You could do that with a simple counter on the model in question. Just have it do it via AJAX and it will be a smooth and nice interaction.

On the other hand if this is admin facing and just flags the comment/post then I would create a table called flags or something like that and it could store the type as a string ("spam" or "reported") and then contain the model name and id (polymorphic). This would give you a list of all the comments/posts that had been flagged or reported and allow you to do whatever you wanted with them.

In actuality the second approach is probably the most flexible since it allows any model to be reported or be considered a spam entry. The only difference is you would be the counter on that model if the UX was user facing.

Anyway, that is a couple of ways to do it. Hope it helps!

Casey, thanks for the suggestions. I appreciate the time taken to help.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 34,885+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.