Sha256: dbb69de65148888d5493d5fb0734240ebc2fc02a3c9509154871d8abb6c4aa3f

Contents?: true

Size: 1.15 KB

Versions: 13

Compression:

Stored size: 1.15 KB

Contents

module  Crowdblog
  class PostsController < Controller
    respond_to :html, :json
    cache_sweeper :post_sweeper

    def index
      @posts = Post.scoped_for(current_user).all_posts_json
      respond_to do |format|
        format.json { render json: @posts }
        format.html
      end
    end

    def create
      @post = Post.new(params[:post])
      @post.author = current_user
      @post.regenerate_permalink
      @post.save
      respond_with @post
    end

    def destroy
      @post = Post.scoped_for(current_user).find(params[:id])
      @post.destroy
      respond_with @post
    end

    def show
      @post = Post.includes(:assets).find(params[:id])
      respond_to do |format|
        format.json { render json: @post.to_json(include: :assets) }
      end
    end

    def update
      @post = Post.scoped_for(current_user).find(params[:id])
      @post.update_attributes(params[:post], updated_by: current_user)
      if @post.allowed_to_update_permalink?
        @post.regenerate_permalink
        @post.save!
      end

      @post.publish_if_allowed(params[:transition], current_user) if params[:transition]

      respond_with @post
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
crowdblog-0.0.16 app/controllers/crowdblog/posts_controller.rb
crowdblog-0.0.15 app/controllers/crowdblog/posts_controller.rb
crowdblog-0.0.14 app/controllers/crowdblog/posts_controller.rb
crowdblog-0.0.13 app/controllers/crowdblog/posts_controller.rb
crowdblog-0.0.12 app/controllers/crowdblog/posts_controller.rb
crowdblog-0.0.10 app/controllers/crowdblog/posts_controller.rb
crowdblog-0.0.9 app/controllers/crowdblog/posts_controller.rb
crowdblog-0.0.8 app/controllers/crowdblog/posts_controller.rb
crowdblog-0.0.7 app/controllers/crowdblog/posts_controller.rb
crowdblog-0.0.6 app/controllers/crowdblog/posts_controller.rb
crowdblog-0.0.5 app/controllers/crowdblog/posts_controller.rb
crowdblog-0.0.4 app/controllers/crowdblog/posts_controller.rb
crowdblog-0.0.3 app/controllers/crowdblog/posts_controller.rb