Skip to content

Instantly share code, notes, and snippets.

@jm
Created February 3, 2010 04:48
Show Gist options
  • Save jm/293333 to your computer and use it in GitHub Desktop.
Save jm/293333 to your computer and use it in GitHub Desktop.
class PostsController < ApplicationController
respond_to :html, :xml
def index
@posts = Post.all
respond_with @posts
end
def show
@post = Post.find(params[:id])
respond_with @post
end
def new
@post = Post.new
respond_with @post
end
def edit
@post = Post.find(params[:id])
end
def create
@post = Post.new(params[:post])
flash[:notice] = 'Post was successfully created.' if @post.save
respond_with @post
end
def update
@post = Post.find(params[:id])
flash[:notice] = 'Post was successfully updated.' if @post.update_attributes(params[:post])
respond_with @post
end
def destroy
@post = Post.find(params[:id])
@post.destroy
respond_with @post
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment