Skip to content

Instantly share code, notes, and snippets.

@joemsak
Created December 13, 2010 21:25
Show Gist options
  • Save joemsak/739621 to your computer and use it in GitHub Desktop.
Save joemsak/739621 to your computer and use it in GitHub Desktop.
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