Sha256: fb4d1479c5f5980df1468a7cf4463c711d89844c0a20d2e569280fa7c94ebfdb

Contents?: true

Size: 1.16 KB

Versions: 22

Compression:

Stored size: 1.16 KB

Contents

class Pulitzer::PostTypesController < Pulitzer::ApplicationController
  before_filter :get_post_type, only: [:show, :edit, :update, :destroy]

  def index
    @post_types = Pulitzer::PostType.all
  end

  def new
    @post_type = Pulitzer::PostType.new
    render partial: 'new', locals: {post_type: @post_type}
  end

  def create
    @post_type = Pulitzer::PostType.create(post_type_params)
    Pulitzer::CreateSingletonPost.new(@post_type, post_params_name).call
    render partial: 'show_wrapper', locals: {post_type: @post_type}
  end

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

  def edit
    render partial: 'form', locals: {post_type: @post_type}
  end

  def update
    @post_type.update_attributes(post_type_params)
    Pulitzer::UpdateSingletonPost.new(@post_type, post_params_name).call
    render partial: 'show', locals: {post_type: @post_type}
  end

  def destroy
    @post_type.destroy
    render nothing: true
  end

  protected

  def post_type_params
    params[:post_type].permit!
  end

  def post_params_name
    params[:post_type][:name]
  end

  def get_post_type
    @post_type = Pulitzer::PostType.find(params[:id])
  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
pulitzer-0.1.6 app/controllers/pulitzer/post_types_controller.rb
pulitzer-0.1.5 app/controllers/pulitzer/post_types_controller.rb