Created
November 1, 2008 10:46
-
-
Save xdite/21497 to your computer and use it in GitHub Desktop.
This file contains 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 BlogsController < ApplicationController | |
def index | |
@posts = Post.find(:all) | |
end | |
def show | |
@post = Post.find(params[:id]) | |
end | |
def new | |
@post = Post.new | |
end | |
def edit | |
@post = Post.find(params[:id]) | |
end | |
def create | |
@post = Post.new(params[:post]) | |
if @post.save | |
flash[:notice] = 'Post was successfully created.' | |
redirect_to blog_path(@post) | |
else | |
render :action => "new" | |
end | |
end | |
def update | |
@post = Post.find(params[:id]) | |
if @post.update_attributes(params[:post]) | |
flash[:notice] = 'Post was successfully updated.' | |
redirect_to blog_path(@post) | |
else | |
format.html { render :action => "edit" } | |
end | |
end | |
def destroy | |
@post = Post.find(params[:id]) | |
@post.destroy | |
redirect_to blogs_path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment