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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:10:05+00:00 2026-05-28T14:10:05+00:00

Rails 3.1, ActiveAdmin 0.3.4. My question is somewhat similar to this one but different

  • 0

Rails 3.1, ActiveAdmin 0.3.4.

My question is somewhat similar to this one but different enough in terms of data modeling that I think it warrants its own response. Models:

class CheckoutRequest < ActiveRecord::Base  
  has_one :request_common_data, :as => :requestable, :dependent => :destroy
end

class RequestCommonData < ActiveRecord::Base
  belongs_to :requestable, :polymorphic => true
end

The RequestCommonData model has a completed field (boolean) that I’d like to be able to filter in ActiveAdmin’s CheckoutRequest index page. I’ve tried a few different approaches to no avail, including the following:

filter :completed, :collection => proc { CheckoutRequest.all.map { |cr| cr.request_common_data.completed }.uniq }

which results in no filter being displayed. Adding :as => :select to the line, as follows:

filter :completed, :as => :select, :collection => proc { CheckoutRequest.all.map { |cr| cr.request_common_data.completed }.uniq }

results in the following MetaSearch error message:

undefined method `completed_eq' for #<MetaSearch::Searches::CheckoutRequest:0x007fa4d8faa558>

That same proc returns [true, false] in the console.

Any suggestions would be quite welcome. Thanks!

  • 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-05-28T14:10:05+00:00Added an answer on May 28, 2026 at 2:10 pm

    From the meta_search gem page you can see that for boolean values the ‘Wheres’ are:

    • is_true – Is true. Useful for a checkbox like “only show admin users”.
    • is_false – The complement of is_true.

    so what you need is to change the generate input name from ‘completed_eq’ to be ‘completed_is_true’ or ‘completed_is_false’.

    The only way I have found this possible to do is with Javascript, since by looking at the Active Admin code, the ‘Wheres’ are hardcoded for each data type.

    I would usually have a line like this in my activeadmin.js file (using jQuery)

    $('#q_completed_eq').attr('name', 'q[completed_is_true]');
    

    or

    $('#q_completed_eq').attr('name', 'q[completed_is_false]');
    

    Terrible and ugly hack but have found no other solution myself.

    Be careful to enable this only in the pages you want.

    — NEW FOR VERSION 0.4.2 and newer —

    Now Active Admin uses separate modules for each :as => … option in the filters.
    So for example you can place the code below inside an initializer file

    module ActiveAdmin
      module Inputs
        class FilterCustomBooleanInput < ::Formtastic::Inputs::SelectInput
          include FilterBase
    
          def input_name
            "#{@method}_is_true"
          end
    
          def input_options
            super.merge(:include_blank => I18n.t('active_admin.any'))
          end
    
          def method
            super.to_s.sub(/_id$/,'').to_sym
          end
    
          def extra_input_html_options
            {}
          end
        end
      end
    end
    

    and the use

    :as => :custom_boolean
    

    where you specify your filter.

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

Sidebar

Related Questions

This is similar to my previous question Ruby On Rails Active Admin has_many changing
This is a bit of a follow-up from a previous question on improving rails
this is a bit of a beginner's question, but I've searched everywhere and can't
I'm using Rails 3, ActiveAdmin and Kaminari. I have this on the documents.rb file
In a Rails app using ActiveAdmin, one of my fields is printing an enormous
Using ActiveAdmin for a rails application (very impressed so far). My question is, when
I'm using ActiveAdmin with Rails 3.1. The only images (that I'm aware of) that
I'm using rails-settings by Squeegy from https://github.com/Squeegy/rails-settings as well as Activeadmin . What I'm
Rails -v 3.2.3 im using kaminari to do pagination but i keep getting a
Rails make It possible to map resources that are logically children of other resources

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.