Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8679303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:56:18+00:00 2026-06-12T20:56:18+00:00

On my site, moderators can flag spammy comments. When these comments are flagged, they

  • 0

On my site, moderators can flag spammy comments. When these comments are flagged, they get quarantined so they no longer appear in regular views, though they can still be seen in the administrative control panel. At the moment, I exclude them from regular views like so:

@comments = Comment.where(:flagged => false)

I do this in every controller that has comments in it, of which there are many. I get the feeling that there’s a cleaner way to handle this in Rails. Perhaps somewhere in the comments model I can specify that when querying for comments, only retrieve those that aren’t flagged. If so, how is that done? And even if that’s not possible, is there some other way to dry this code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:56:19+00:00Added an answer on June 12, 2026 at 8:56 pm

    u can use a default scope

    default_scope where(:flagged => false)
    

    see http://apidock.com/rails/ActiveRecord/Base/default_scope/class

    the default scope can be ignored using unscoped. See http://apidock.com/rails/ActiveRecord/Base/unscoped/class

    i would prefer using a scope rather a default scope since i dont have to override it when all the records are needed. Depends upon the frequency of fetching all/unflagged records.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After registering on my site I can make people moderators which just changes 1
I came up with my own way to protect the moderators on my site.
Site: http://na.leagueoflegends.com/ladders/solo-5x5 Search for a a player (example: Jaiybe) You get redirected (in this
I tried to use a Facebook comment plugin so that I can moderate comments
site.com/page1.php?a=1&b=2,how to replace a=1 to a=3? and get a new url string.
I am doing a site in cakephp where users can upload videos and those
I'm using facebook's comments plugin on my site and on my blog. One of
Site 1 has dll's for x amount of object and data calls. Can Site
Site loads fine in IE8,9,FF & Chrome. I can't seem to remedy the issue
Site A will be generating a set of records. Nightly they will backup their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.