I have a Class Company with a boolean attribute of female_founder. The company either has a female_founder (true) or not (false).
I have created a search filter using the ransack gem to query whether a company is female-founded or not. When I query 'true' searches, the enum value saves and displays fine, but when I search for the 'false' value, the display resets to the prompt value I have given it.
Why is this? And how can I fix it? I want the display to show whichever value I have selected.
Schema
create_table "companies", force: :cascade do |t|
...
t.boolean "female_founder"
...
end
Company.rb
class Company < ApplicationRecord
enum female_founders: {
'Yes' => 1,
'No' => 0
}
end
Search.html.erb
<%= f.label :female_founder_eq, 'Female Founder' %>
<%= f.select :female_founder_eq, Company.female_founders.to_a, {prompt: "Any"} %>
Search 'Yes' for female_founder returns correct display
Search 'No' for female_founder resets search display to prompt value.
The search queries correctly, it is just the display that is incorrect.


params[:q][: female_founder_eq]?