I have an amenities model that basically has a bunch of boolean columns.
I want to display the True columns in views, so I would like to filter out the false columns at the model level.
My initial thinking:
# in model file
def available
a = {}
self.attributes.each do |key, value|
if value
a[key] = value
end
end
a
end
This is not perfect since it gives me the id, created_at, and modified_at columns.
I feel like there must be a better way to achieve this.
Using @Deefour suggestion I ended up with this: