Skip to content

Commit

Permalink
fix cache action link urls
Browse files Browse the repository at this point in the history
  • Loading branch information
scambra committed Mar 2, 2015
1 parent 47435d7 commit 6f637d6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/active_scaffold/helpers/view_helpers.rb
Expand Up @@ -235,8 +235,8 @@ def cache_action_link_url?(link, record)

def cached_action_link_url(link, record)
@action_links_urls ||= {}
@action_links_urls[link.name_to_cache] ||= begin
url_options = action_link_url_options(link, record)
@action_links_urls[link.name_to_cache] || begin
url_options = cached_action_link_url_options(link, record)
if cache_action_link_url?(link, record)
@action_links_urls[link.name_to_cache] = url_for(url_options)
else
Expand Down Expand Up @@ -315,18 +315,18 @@ def cache_action_link_url_options?(link, record)
active_scaffold_config.cache_action_link_urls && (link.type == :collection || !link.dynamic_parameters.is_a?(Proc)) && !is_sti_record?(record)
end

def action_link_url_options(link, record)
def cached_action_link_url_options(link, record)
@action_links_url_options ||= {}
@action_links_url_options[link.name_to_cache] ||= begin
options = generate_action_link_url_options(link, record)
@action_links_url_options[link.name_to_cache] || begin
options = action_link_url_options(link, record)
if cache_action_link_url_options?(link, record)
@action_links_url_options[link.name_to_cache] = options
end
options
end
end

def generate_action_link_url_options(link, record)
def action_link_url_options(link, record)
url_options = {:action => link.action}
url_options[:id] = '--ID--' unless record.nil?
url_options[:controller] = link.controller.to_s if link.controller
Expand Down Expand Up @@ -354,7 +354,7 @@ def action_link_text(link, options)
end

def replaced_action_link_url_options(link, record)
url = action_link_url_options(link, record)
url = cached_action_link_url_options(link, record)
url[:controller] ||= params[:controller]
missing_options, url_options = url.partition { |_, v| v.nil? }
replacements = {}
Expand Down

0 comments on commit 6f637d6

Please sign in to comment.