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

  • SEARCH
  • Home
  • 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 8870623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:46:58+00:00 2026-06-14T17:46:58+00:00

I have an app where users are approved by an admin after registering. I

  • 0

I have an app where users are approved by an admin after registering. I need a little help filtering out the admins in the members list.

This is my index method:

def index
  if params[:is_approved].to_i == 0
    @users = User.find_all_by_is_approved(0) #returns all unapproved users
  else
    @users = User.find_all_by_is_approved(1) #here I wanna filter out the admins
  end   
end

I tried to add && User.find_all_by_is_admin(0) but then I get all the users that are not admins, i.e., the unapproved users.

Admins are users but have a column is_admin set to true, and I dont want to display them.

  • 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-14T17:46:59+00:00Added an answer on June 14, 2026 at 5:46 pm

    If you want the list of users who are approved but aren’t admins:

    User.where(:is_approved => 1, :is_admin => 0)
    

    or if you want to write it in the style you were using you could do:

    User.find_all_by_is_approved_and_is_admin(1, 0)
    

    The reason why what you’re trying isn’t working is because && is the boolean AND operator so if you write

    User.find_all_by_is_approved(1) && User.find_all_by_is_admin(0)
    

    Both sides of the && here are considered true so this evaluates to the right-hand side i.e. User.find_all_by_is_admin(0)

    There is an & (single & sign) operator on arrays in Ruby that gives the intersection of 2 arrays i.e.

    User.find_all_by_is_approved(1) & User.find_all_by_is_admin(0)
    

    would be the list of users who are in both lists, but this is an inefficient way of doing it as it results in 2 separate database queries.

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

Sidebar

Related Questions

Newly signed up users to my little app must be approved by the admin
Where can I view the list of permissions that my users have approved? Initially
I have an app where users can change a toggle value between true and
I have an app where users can sign up with Facebook, in which case
I have this code App.Model('users').find(function (err, users) { users.forEach(function(user) { console.log(user.username); }); }); //make
I have an app that allows users to upload large data files and then
I have an app in which users can follow law firms I have 3
I can't send email to my app users, even though I have the permissions.
I have an app and Im saving the users uploaded images to Amazon S3.
I have an iPhone app that allows users to record videos and I'd like

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.