Created
February 24, 2015 19:25
-
-
Save kareemgrant/09ff2aed6793d0080050 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 | |
def index | |
@posts = Post.all | |
end | |
def show | |
@post = Post.find_by_id(params[:id]) | |
end | |
def edit | |
@post = Post.find_by_id(params[:id]) | |
end | |
def new | |
@post = Post.new | |
end | |
def create | |
@post = Post.new(params[:post]) | |
if @post.save | |
redirect_to post_path(@post) | |
end | |
end | |
def destroy | |
@post = Post.find_by_id(params[:id]) | |
@post.destroy | |
flash[:notice] = "This post was deleted" | |
redirect_to posts_path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment