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 8602019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:58:45+00:00 2026-06-12T01:58:45+00:00

I have a model Phone with checked_by field; if this field is equal to

  • 0

I have a model Phone with checked_by field; if this field is equal to 1, then we know this phone is unchecked, else(>1) – checked. On admin side I can review a list of Phones and I need to create a filter using meta_search to review:

  • All Phones
  • Checked
  • Unchecked

I can see checked_by_greater_than, or checked_by_less_than methods in meta_search, but how to combine those methods in a single select box?

Thanks in any advise

  • 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-12T01:58:46+00:00Added an answer on June 12, 2026 at 1:58 am

    With a scope and a made-up field.

    The scope:

    class Phone < ActiveRecord::Base
    
      scope :checked, lambda { |value| 
          !value.zero? ? checked_by_greater_than(1) : where(:checked_by => 1)
      }
    
    end
    

    Then add a select-box with three values, returning [nil, 0, 1] as values, and in your controller use that parameter to apply the new scope.

    class PhonesController < ApplicationController
    
      def index
    
        # ...
        @phones ||= Phone.scoped
        checked_select_value = params.delete("checked_select") # here use the name of your form field
        if checked_select_value.present?
          @phones = @phones.checked(checked_select_value.to_i)
        end
        # now apply the rest of your meta-search things to the @phones
    
        #
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Phone model nested to Message model. How can I find all
I have a model class, with a property like this: [Display(Name = Phone, Description=Hello
I have a contact model, this includes name, address, phone number, etc. I have
I have Pupil model. So i can save and edit pupil. Pupils has_one Phone
I have a model like this, how can I loop through it and not
I have the following models: class Profile(models.Model): verified = models.BooleanField(default=False) primary_phone = models.OneToOneField('Phone', related_name='is_primary',
I have model Foo which has field bar. The bar field should be unique,
I have model Article it has field title with some text that may contain
I have model: # encoding: utf-8 class Tag include Mongoid::Document field :name, type: String
I have model like this: scope :search_posts, lambda { |query| mega_posts.where( title 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.