Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

90 lines (73 sloc) 2.175 kb
class PeopleController < ApplicationController
before_filter :set_as_private, :only => 'new'
# GET /people
# GET /people.json
def index
@people = Person.scoped
# Add last_modified header based on @people last update time.record
# public value implies the cache can be stored in a proxy as Rack::Cache
fresh_when last_modified: @people.maximum(:updated_at), public: true
end
# GET /people/1
# GET /people/1.json
def show
@person = Person.find(params[:id])
# Fix the Cache-Control header value max-age to 1000 seconds by default
expires_in 1000.seconds
# Set Cache-Control header no-cache
if params[:id] == '1'
expires_now
end
end
# GET /people/new
# GET /people/new.json
def new
@person = Person.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @person }
end
end
# GET /people/1/edit
def edit
@person = Person.find(params[:id])
end
# POST /people
# POST /people.json
def create
@person = Person.new(params[:person])
respond_to do |format|
if @person.save
format.html { redirect_to @person, notice: 'Person was successfully created.' }
format.json { render json: @person, status: :created, location: @person }
else
format.html { render action: "new" }
format.json { render json: @person.errors, status: :unprocessable_entity }
end
end
end
# PUT /people/1
# PUT /people/1.json
def update
@person = Person.find(params[:id])
respond_to do |format|
if @person.update_attributes(params[:person])
format.html { redirect_to @person, notice: 'Person was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @person.errors, status: :unprocessable_entity }
end
end
end
# DELETE /people/1
# DELETE /people/1.json
def destroy
@person = Person.find(params[:id])
@person.destroy
respond_to do |format|
format.html { redirect_to people_url }
format.json { head :no_content }
end
end
end
Jump to Line
Something went wrong with that request. Please try again.