Created
October 4, 2011 00:38
-
-
Save 0xSventek/1260639 to your computer and use it in GitHub Desktop.
projects_controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProjectsController < ApplicationController | |
before_filter :get_base_project, :only => [:next,:previous] | |
before_filter :force_js_content_type, :only => [:next,:previous] | |
caches_action :next, :cache_path => proc{ |c| "/projects/" + (c.get_base_project.next.cache_key rescue "nil")}, :expires_in => 15.minutes | |
caches_action :previous, :cache_path => proc{ |c| "/projects/" + (c.get_base_project.previous.cache_key rescue "nil")}, :expires_in => 15.minutes | |
def next | |
@project = @base_project.next | |
render :switch_project | |
end | |
def previous | |
@project = @base_project.previous | |
render :switch_project | |
end | |
protected | |
def get_base_project | |
@base_project = Period.find(params[:base_project_id]) | |
end | |
def force_js_content_type | |
response.headers["Content-Type"] = "text/javascript" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment