Sha256: d18537ac786e408fcd90d76963f1d3d7a8dcac94cb83f332cbb0055dc0637dd7

Contents?: true

Size: 1.26 KB

Versions: 26

Compression:

Stored size: 1.26 KB

Contents

class ApplicationController < ActionController::Base
    protect_from_forgery

    helper :all
    before_filter :translate_entity_keys
    layout Proc.new { |controller| controller.request.xhr? ? nil : 'application' }

    caches_page :load, :client_notify

    def load

    end

    # this should not make it to the server, but if it does, don't throw an error.
    # this makes Jonas happy.
    def client_notify
        render :text => 'say yah to da up, eh?'
    end

    # http://www.treyconnell.com/automatically-raise-recordnotfound-exceptions-rails/
    # any time we get a RecordNotFound Exception we're going to rescue from it and throw a 404
    # rescue_from ActiveRecord::RecordNotFound, :with => :not_found

    # Used to take the user to a 404 page
    # def throw_404
    #     @browser_title = "Page Not Found"
    #     render_optional_error_file("404")
    #     true
    # end

    protected

    # TSN's entity keys contain periods which confuse Rails' page caching system. These are converted
    # on the client to underscores and translated here, back into periods, so that they match the
    # TSN IDs. For example, l_nfl_com-t_9 is converted back to l.nfl.com-t.9.
    def translate_entity_keys
        params[:key].gsub!(/_/, ".") if params[:key]
    end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
sports_db-0.2.19 app/controllers/application_controller.rb
sports_db-0.2.18 app/controllers/application_controller.rb
sports_db-0.2.17 app/controllers/application_controller.rb
sports_db-0.2.16 app/controllers/application_controller.rb
sports_db-0.2.15 app/controllers/application_controller.rb
sports_db-0.2.14 app/controllers/application_controller.rb
sports_db-0.2.13 app/controllers/application_controller.rb
sports_db-0.2.12 app/controllers/application_controller.rb
sports_db-0.2.11 app/controllers/application_controller.rb
sports_db-0.2.10 app/controllers/application_controller.rb
sports_db-0.2.9 app/controllers/application_controller.rb
sports_db-0.2.8 app/controllers/application_controller.rb
sports_db-0.2.7 app/controllers/application_controller.rb
sports_db-0.2.6 app/controllers/application_controller.rb
sports_db-0.2.5 app/controllers/application_controller.rb
sports_db-0.2.4 app/controllers/application_controller.rb
sports_db-0.2.3 app/controllers/application_controller.rb
sports_db-0.2.2 app/controllers/application_controller.rb
sports_db-0.2.1 app/controllers/application_controller.rb
sports_db-0.2 app/controllers/application_controller.rb