Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean filter not working #5318

Closed
8vius opened this issue Jan 15, 2018 · 8 comments
Closed

Boolean filter not working #5318

8vius opened this issue Jan 15, 2018 · 8 comments

Comments

@8vius
Copy link

8vius commented Jan 15, 2018

I'm trying to filter by a boolean column on my Users table and I've tried making it a select box and check box, neither method works

filter :admin_created
filter :admin_created, collection: [["Yes", true], ["No", false]]
filter :admin_created, as: :select, collection: [["Yes", true], ["No", false]]
filter :admin_created, as: :check_boxes, collection: [["Yes", true], ["No", false]]

Neither of the above filter properly:

screen shot 2018-01-15 at 12 45 02 pm

@joshmn
Copy link

joshmn commented Jan 20, 2018

Are you able to reproduce this on the demo app? https://github.com/activeadmin/demo.activeadmin.info

@zorab47
Copy link
Contributor

zorab47 commented Jan 23, 2018

Is admin_created the name of the column? What SQL is generated in the Rails log when the filter is applied?

@8vius
Copy link
Author

8vius commented Jan 23, 2018

@zorab47 yeah admin created is the name of the column. @joshmn let me try and replicate in the demo.

@wspurgin
Copy link
Contributor

Is the column a boolean column? (i.e. what does User.columns_hash[:admin_created].type return?)

If you want to force the boolean filter rendering you have to add the as: :boolean option to the filter declaration.

@8vius
Copy link
Author

8vius commented Jan 31, 2018

@wspurgin yes the column is a boolean value.

@wspurgin
Copy link
Contributor

@8vius Have you also tried forcing the boolean representation?

filter :admin_created, as: :boolean

The default filter should have produced the typical "Yes/No" drop down like the one for the Feature filter on the Product resource page of the demo. If forcing the as: :boolean still doesn't work, here are my next two questions:

  1. What version of AA are you using?
  2. Do you have an custom CSS or styling in your app (at all).

From what I can see in the photo you posted, it looks like you're using an older version of AA (just based on the styling), but without knowing more information, I'm not sure we can help you much more than we have already.

@varyonic
Copy link
Contributor

I’m going to close this since you haven’t responded. Please feel free to update this issue with additional information so it can be reconsidered.

@ntloi95
Copy link

ntloi95 commented Dec 22, 2019

@8vius Have you also tried forcing the boolean representation?

filter :admin_created, as: :boolean

The default filter should have produced the typical "Yes/No" drop down like the one for the Feature filter on the Product resource page of the demo. If forcing the as: :boolean still doesn't work, here are my next two questions:

  1. What version of AA are you using?
  2. Do you have an custom CSS or styling in your app (at all).

From what I can see in the photo you posted, it looks like you're using an older version of AA (just based on the styling), but without knowing more information, I'm not sure we can help you much more than we have already.

Force using as: :boolean is worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants