Sha256: d30eb181d87873a789c57bf24e1f80ae5b9e0c2eb63fc8d37dbfdabe6f285120

Contents?: true

Size: 1.01 KB

Versions: 11

Compression:

Stored size: 1.01 KB

Contents

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

  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
    render partial: 'form', locals: { post: @post }
  end

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

  def destroy
    @post.destroy
    render head :ok
  end

  protected

  def post_params
    params[:post].permit!
  end

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

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pulitzer-0.2.2 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.2.1 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.2.0 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.1.10 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.1.9 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.1.8 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.1.7 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.1.6 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.1.5 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.1.4 app/controllers/pulitzer/posts_controller.rb
pulitzer-0.1.3 app/controllers/pulitzer/posts_controller.rb