Skip to content

Instantly share code, notes, and snippets.

@aeden
Created February 5, 2010 21:27
Show Gist options
  • Select an option

  • Save aeden/296266 to your computer and use it in GitHub Desktop.

Select an option

Save aeden/296266 to your computer and use it in GitHub Desktop.
class PeopleController < ApplicationController
def index
@people = Person.all
end
def create
@person = Person.new(params[:person])
@person.save!
respond_to do |format|
format.html { redirect_to people_url }
format.json { render :json => @person }
end
rescue ActiveRecord::RecordInvalid => e
render :action => 'new'
end
def delete
@person = Person.find(params[:id])
end
def destroy
@person = Person.find(params[:id])
@person.destroy
respond_to do |format|
format.html { redirect_to people_url }
format.json { render :json => true }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment