Created
December 13, 2010 21:25
-
-
Save joemsak/739621 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 Admin::Blog::PostsController < Admin::BaseController | |
crudify :blog_post, | |
:title_attribute => :title, | |
:order => 'published_at DESC' | |
before_filter :find_all_categories, | |
:only => [:new, :edit, :create, :update] | |
def new | |
@blog_post = current_user.blog_posts.build | |
end | |
def create | |
@blog_post = current_user.blog_posts.new(params[:blog_post]) | |
if @blog_post.save | |
redirect_to [:admin, :index], :notice => 'Blog post was created!' | |
else | |
render :action => :new | |
end | |
end | |
protected | |
def find_all_categories | |
@blog_categories = BlogCategory.find(:all) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment