I have a filter
#in cities.rb
filter :country #drop-down select list with more than 200 values
It almost static list, i need to cache it for better productivity
I've tried
filter :country, :collection=>proc{cache {options_from_collection_for_select(Country.all, :id, :name)}} #no luck
Thank you
Try something like this:
EDIT: I've changed my code samples based on comment feedback.
EDIT: I've update the sample to include html generation.
# In activeadmin
filter :country, :collection => proc do
Rails.cache.fetch('countries_for_select') do
options_from_collection_for_select(Country.all, :id, :name)}
end
end
# Somewhere, when you want to expire the cache
Rails.cache.delete('countries_for_select')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With