Sha256: 096b5940de450a2991d1e00690d96af6bcb139b85459347f1bf4aae67535e524
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
class Sb::Admin::PostsController < SbController protect_from_forgery before_filter :find_post, :only => [:edit, :update, :destroy, :publish] before_filter :require_user def index @posts = Post.recent.paginate(:all, :page=>params[:page], :per_page=>20) end def create @post = Post.new(params[:post]) @post.title = Hpricot(params[:post][:title]).inner_text @post.user = current_user @post.save! redirect_to root_path rescue render :action => :new end def edit end def update @post.update_attributes(params[:post]) @post.title = Hpricot(params[:post][:title]).inner_text @post.save! redirect_to root_path rescue render :edit end def destroy @post.destroy redirect_to root_path end def publish @post.published = params[:set]=="1" ? true : false @post.save respond_to do |format| format.html { redirect_to :back } format.js { render :update do |page| page.replace_html "publish_#{@post.id}", :partial => "publish", :locals=>{:publish=>@post} end } end end private def find_post @post = Post.find_by_slug(params[:id]) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
santey_blog-0.2.1 | app/controllers/sb/admin/posts_controller.rb |
santey_blog-0.2.0 | app/controllers/sb/admin/posts_controller.rb |