Sha256: be8361320f5407fcce1d26310697fb09c53ca79d649e1e0280d7f286f9acf69e

Contents?: true

Size: 1.4 KB

Versions: 14

Compression:

Stored size: 1.4 KB

Contents

class Pulitzer::PostsController < Pulitzer::ApplicationController
  before_filter :get_post, only: [:show, :edit, :edit_slug, :update,
    :update_slug, :processing_preview]

  def index
    @post_type = Pulitzer::PostType.find params[:post_type_id]
    @posts = Pulitzer::Post.where post_type: @post_type
  end

  def new
    @post = Pulitzer::Post.new(post_type_id: params[:post_type_id])
    render partial: 'new', locals: { post: @post }
  end

  def create
    @post = Pulitzer::Post.create(post_params)
    Pulitzer::CreatePostContentElements.new(@post).call if @post
    render partial: 'show_wrapper', locals: { post: @post }
  end

  def show
    render partial: 'show', locals: { post: @post }
  end

  def edit
    if request.xhr?
      render partial: 'form', locals: { post: @post }
    end
  end

  def update
    @post.update_attributes(post_params)
    render partial: 'show', locals: { post: @post }
  end

  def destroy
    @post.destroy
    render head :ok
  end

  def edit_slug
    if request.xhr?
      render partial: 'form_slug', locals: { post: @post }
    end
  end

  def show_slug
    render partial: 'show_slug', locals: { post: @post }
  end

  def update_slug
    @post.update_attributes(post_params)
    render partial: 'show_slug', locals: { post: @post }
  end

  protected

  def post_params
    params[:post].permit!
  end

  def get_post
    @post = Pulitzer::Post.find(params[:id])
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pulitzer-0.5.5 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.5.4 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.5.3 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.5.2 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.5.1 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.5.0 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.4.16 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.4.15 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.4.14 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.4.13 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.4.12 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.4.11 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.4.10 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.4.9 app/controllers/pulitzer/posts_controller.rb