You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
how can I use a search form with a checkbox
that would include or exclude the desired active scope ? I've tried the code below but it doesn't seem to work
= search_form_for @q, url: products_example_path do |f|
= f.check_box :active
The text was updated successfully, but these errors were encountered:
Do you mean true => Product.active and false => Product.all? Or do you want active vs. inactive exclusively?
Ransack can pass params to your scope if they come as an array. So, something like this is possible:
scope :active, ->(yes=true) { where(active: yes) }
# so you can do Product.active(true) and Product.active(false)
Product.search(active: [true])
Product.search(active: [false])
If Ransack receives the scope params as an array, it passes that through. (Note there are some issues with type conversion though, see #509)
Hello guys/girls I am trying to use a search_form_for and ransack scope but it doesn't seem to work
I have a product model
In my controller:
how can I use a search form with a checkbox
that would include or exclude the desired active scope ? I've tried the code below but it doesn't seem to work
The text was updated successfully, but these errors were encountered: