forked from hacketyhack/hackety-hack.com
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a829e4d
commit 87bebf7
Showing
1 changed file
with
9 additions
and
5 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
class BlogController < ApplicationController | ||
before_filter :authenticate_user!, :only => [:admin, :create] | ||
|
||
def index | ||
@posts = BlogPost.all.reverse | ||
end | ||
|
||
def create | ||
@post = BlogPost.create(params[:blog_post]) | ||
redirect_to admin_blog_index_path, :notice => "Blog Post created!" | ||
end | ||
|
||
def show | ||
@post = BlogPost.find(params[:id]) | ||
end | ||
|
||
def admin | ||
redirect_to blog_index unless current_user.blog_poster | ||
@post = BlogPost.new | ||
@posts = BlogPost.all.reverse | ||
end | ||
|
||
def create | ||
redirect_to blog_index unless current_user.blog_poster | ||
@post = BlogPost.create(params[:blog_post]) | ||
redirect_to admin_blog_index_path, :notice => "Blog Post created!" | ||
end | ||
end |