Displaying 1 result from an estimated 1 matches for "cache_countries_for_select".
Did you mean:
cached_countries_for_select
2008 Mar 01
2
How to cache data in a plugin
...the page is loaded.
The problem is that the plugin initializes its main @countries
variable in init.rb file by calling method
CountryCodes.load_countries_from_yaml.
Is there an easier way to cache this data than doing something like
this:
lib/country_codes.rb
module CountryCodes
...
def self.cache_countries_for_select
@cached_countries_for_select = countries_for_select(''name'',
''a2'').sort.freeze
end
def self.cached_countries_for_select
@cached_countries_for_select
end
...
end
init.rb
require ''country_codes''
CountryCodes.load_countries_from_yam...