Sha256: 6d74a8c94f3d3fdf8ba7de2d1df11435485cbdcb64f76e300181fafaace0b59d

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

class ApplicationController < ActionController::Base
    protect_from_forgery

    helper :all
    before_filter :translate_entity_keys
    layout 'application', :only => :load

    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

5 entries across 5 versions & 1 rubygems

Version Path
sports_db-0.0.8 app/controllers/application_controller.rb
sports_db-0.0.7 app/controllers/application_controller.rb
sports_db-0.0.6 app/controllers/application_controller.rb
sports_db-0.0.5 app/controllers/application_controller.rb
sports_db-0.0.4 app/controllers/application_controller.rb