class ApplicationController

Public Class Methods

expire_cache() click to toggle source
# File app/controllers/application_controller.rb, line 13
def self.expire_cache
  begin
    FileUtils.rm_rf(File.join(::Rails.root.to_s, "public", "bar"))
    FileUtils.rm_rf(File.join(::Rails.root.to_s, "public", "cat4_womens_race_series"))
    FileUtils.rm_rf(File.join(::Rails.root.to_s, "public", "competitions"))
    FileUtils.rm_rf(File.join(::Rails.root.to_s, "public", "events"))
    FileUtils.rm_rf(File.join(::Rails.root.to_s, "public", "people"))
    FileUtils.rm_rf(File.join(::Rails.root.to_s, "public", "rider_rankings"))
    FileUtils.rm_rf(File.join(::Rails.root.to_s, "public", "results"))
    FileUtils.rm_rf(File.join(::Rails.root.to_s, "public", "schedule"))
    FileUtils.rm_rf(File.join(::Rails.root.to_s, "public", "teams"))
    FileUtils.rm(File.join(::Rails.root.to_s, "public", "bar.html"), :force => true)
    FileUtils.rm(File.join(::Rails.root.to_s, "public", "cat4_womens_race_series.html"), :force => true)
    FileUtils.rm(File.join(::Rails.root.to_s, "public", "home.html"), :force => true)
    FileUtils.rm(File.join(::Rails.root.to_s, "public", "index.html"), :force => true)
    FileUtils.rm(File.join(::Rails.root.to_s, "public", "results.html"), :force => true)
    FileUtils.rm(File.join(::Rails.root.to_s, "public", "rider_rankings.html"), :force => true)
    FileUtils.rm(File.join(::Rails.root.to_s, "public", "schedule.html"), :force =>true)
    FileUtils.rm(File.join(::Rails.root.to_s, "public", "teams.html"), :force =>true)
  rescue Exception => e
    logger.error e
  end
  
  true
end

Protected Instance Methods

clear_racing_association() click to toggle source
# File app/controllers/application_controller.rb, line 42
def clear_racing_association
  RacingAssociation.current = nil
end
expire_cache() click to toggle source
# File app/controllers/application_controller.rb, line 50
def expire_cache
  if perform_caching
    ApplicationController.expire_cache
  end
end
render_404() click to toggle source
# File app/controllers/application_controller.rb, line 77
def render_404
  respond_to do |type|
    type.html {
      local_path = "#{Rails.root}/local/public/404.html"
      if File.exists?(local_path)
        render :file => "#{::Rails.root.to_s}/local/public/404.html", :status => "404 Not Found"
      else
        render :file => "#{::Rails.root.to_s}/public/404.html", :status => "404 Not Found"
      end
    }
    type.all  { render :nothing => true, :status => "404 Not Found" }
  end
end
render_500() click to toggle source
# File app/controllers/application_controller.rb, line 91
def render_500
  respond_to do |type|
    type.html {
      local_path = "#{Rails.root}/local/public/500.html"
      if File.exists?(local_path)
        render :file => "#{::Rails.root.to_s}/local/public/500.html", :status => "500 Error"
      else
        render :file => "#{::Rails.root.to_s}/public/500.html", :status => "500 Error"
      end
    }
    type.all  { render :nothing => true, :status => "500 Error" }
  end
end
render_page(path = nil) click to toggle source
# File app/controllers/application_controller.rb, line 56
def render_page(path = nil)
  unless path
    path = controller_path
    path = "#{path}/#{action_name}" unless action_name == "index"
  end
  
  page_path = path.dup
  page_path.gsub!(%r.html$/, "")
  page_path.gsub!(%rindex$/, "")
  page_path.gsub!(%r\/$/, "")
  
  if mobile_request?
    page_path = "mobile#{page_path}"
  end

  @page = Page.find_by_path(page_path)
  if @page
    render(:inline => @page.body, :layout => true)
  end
end
toggle_tabs() click to toggle source
# File app/controllers/application_controller.rb, line 46
def toggle_tabs
  @show_tabs = false
end