Created
March 10, 2011 21:28
-
-
Save datapimp/864964 to your computer and use it in GitHub Desktop.
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 SectionsController < ApplicationController | |
| before_filter :require_client | |
| def index | |
| cache_key = "#{ current_package.id }:sections" | |
| @sections = Rails.cache.read cache_key | |
| if !@sections | |
| @sections = Section.tree_for( current_package ) | |
| Rails.cache.write cache_key, @sections | |
| else | |
| Rails.logger.info "Cache Hit on #{ cache_key }" | |
| end | |
| respond_to do |format| | |
| format.json { render :json => jsonp_wrap(@sections) } | |
| format.html { render :layout => false } | |
| format.xml { render :xml => @sections } | |
| end | |
| end | |
| def show | |
| @section = current_package.sections.find( params[:id] ) | |
| respond_to do |format| | |
| format.json { render :json => jsonp_wrap(@section) } | |
| format.html { render :layout => false } | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment