Created
February 3, 2010 04:48
-
-
Save jm/293333 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 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