Sha256: 4b6a6411df9da9d5c170f43bdcb7796e71b2806c310a94eff32fdfa395a3ef4d
Contents?: true
Size: 1.76 KB
Versions: 7
Compression:
Stored size: 1.76 KB
Contents
module Blogit class PostsController < ApplicationController unless blogit_conf.include_admin_actions before_filter :raise_404, except: [:index, :show, :tagged] end blogit_authenticate(except: [:index, :show, :tagged]) blogit_cacher(:index, :show, :tagged) blogit_sweeper(:create, :update, :destroy) def index respond_to do |format| format.xml { @posts = Post.order('created_at DESC') } format.html { @posts = Post.for_index(params[:page]) } end end def show @post = Post.find(params[:id]) @comment = @post.comments.new end def tagged @posts = Post.for_index(params[:page]).tagged_with(params[:tag]) render :index end def new @post = current_blogger.blog_posts.new(params[:post]) end def edit @post = current_blogger.blog_posts.find(params[:id]) end def create @post = current_blogger.blog_posts.new(params[:post]) if @post.save redirect_to @post, notice: 'Blog post was successfully created.' else render action: "new" end end def update @post = current_blogger.blog_posts.find(params[:id]) if @post.update_attributes(params[:post]) redirect_to @post, notice: 'Blog post was successfully updated.' else render action: "edit" end end def destroy @post = current_blogger.blog_posts.find(params[:id]) @post.destroy redirect_to posts_url, notice: "Blog post was successfully destroyed." end private def raise_404 # Don't include admin actions if include_admin_actions is false render file: "#{Rails.root}/public/404.html", status: :not_found, layout: false end end end
Version data entries
7 entries across 7 versions & 1 rubygems