module ActionView # Prefer controller-specific templates and partials if they exist. # Otherwise, use files in the layouts folder. class Base private def full_template_path(template_path, extension) # Prefer shared partial first (Rails default) shared_path = "#{@base_path}/#{template_path}.#{extension}" # Prefer the controller-specific (regular) partial second private_path = "#{@base_path}/#{template_path}.#{extension}" # Check to see if the partial exists in our "default" folder last default_path = ("#{@base_path}/default/#{template_path.split("/")[1]}.#{extension}" rescue private_path) if File.exist?(shared_path) shared_path elsif File.exist?(private_path) private_path elsif File.exist?(default_path) default_path else # Even though the preferred file doesn't exist, return it # so a reasonable error message can be given private_path end end end end