Skip to content

Commit

Permalink
Fixed caching of select options
Browse files Browse the repository at this point in the history
  • Loading branch information
cykod committed Oct 26, 2010
1 parent f20fdc7 commit 508e4b2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/models/content/core_field.rb
Expand Up @@ -731,7 +731,7 @@ def form_field(f,field_name,field_opts,options={})
opts = { :conditions => conditions,:order => order_by, :group_by_id => options[:group_by_id] }
opt_hsh = cls.hash_hash(opts)

available_options = cls.cache_fetch(opt_hsh,'select_options_grouped')
available_options = cls.cache_fetch_list(opt_hsh+'select_options_grouped')

if !available_options
all_elems = cls.find(:all,:conditions => conditions, :order => order_by)
Expand All @@ -741,23 +741,23 @@ def form_field(f,field_name,field_opts,options={})
end
available_options = available_options.to_a.sort { |a,b| a[0] <=> b[0] }

cls.cache_put(opt_hsh,available_options,'select_options_grouped')
cls.cache_put_list(opt_hsh+"select_options_grouped",available_options)
end

control = :grouped_check_boxes

else
opts = { :conditions => conditions,:order => order_by }
opt_hsh = cls.hash_hash(opts)
available_options = cls.cache_fetch(opt_hsh,'select_options')
available_options = cls.cache_fetch_list(opt_hsh + 'select_options')

if !available_options
available_options = cls.select_options(opts)
if !order_by
available_options.sort! { |a,b| a[0].downcase <=> b[0].downcase }
end

cls.cache_put(opt_hsh,available_options,'select_options')
cls.cache_put_list(opt_hsh + 'select_options',available_options)
end


Expand Down

0 comments on commit 508e4b2

Please sign in to comment.