Sha256: 30f9dcace985a5e449ece283cfe27c638fc95fba25e980dd9673b23970fe98c0
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
class Monologue::Admin::PostsController < Monologue::Admin::BaseController respond_to :html cache_sweeper Monologue::PostsSweeper, :only => [:create, :update, :destroy] def index @posts = Monologue::Post.default end def new @post = Monologue::Post.new @revision = @post.posts_revisions.build end def create params[:post][:posts_revisions_attributes] = {} params[:post][:posts_revisions_attributes][0] = params[:post][:posts_revision] params[:post].delete("posts_revision") @post = Monologue::Post.new(params[:post]) @revision = @post.posts_revisions.first @revision.user_id = current_user.id if @post.save redirect_to edit_admin_post_path(@post), :notice => 'Monologue created' else render :action => "new" end end def edit @post = Monologue::Post.includes(:posts_revisions).find(params[:id]) @revision = @post.posts_revisions.last end def update @post = Monologue::Post.includes(:posts_revisions).find(params[:id]) @post.published = params[:post][:published] @revision = @post.posts_revisions.build(params[:post][:posts_revision]) @revision.user_id = current_user.id if @post.save redirect_to edit_admin_post_path(@post), :notice => 'Monologue saved' else render :edit end end def destroy post = Monologue::Post.find(params[:id]) if post.destroy redirect_to admin_posts_path, :notice => "Monologue removed" else redirect_to admin_posts_path, :alert => "Failed to remove monologue!" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
monologue-0.1.0 | app/controllers/monologue/admin/posts_controller.rb |