Sha256: 2733d9abcf5705c866c369dc13edb2e4607d8aef9d786a4629024832137a0abd

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

class Pulitzer::PostTypesController < Pulitzer::ApplicationController
  before_filter :get_post_type, except: [:index, :new, :create]

  def index
    if params[:post_type_kind]
      @post_type_kind = params[:post_type_kind]
    else
      @post_type_kind = 'template'
    end
    if request.xhr?
      @post_types = Pulitzer::PostType.send @post_type_kind
      render_ajax
    end
  end

  def new
    @post_type = Pulitzer::PostType.new(post_type_params)
    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 template
    render_ajax 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

4 entries across 4 versions & 1 rubygems

Version Path
pulitzer-0.4.8 app/controllers/pulitzer/post_types_controller.rb
pulitzer-0.4.7 app/controllers/pulitzer/post_types_controller.rb
pulitzer-0.4.6 app/controllers/pulitzer/post_types_controller.rb
pulitzer-0.4.5 app/controllers/pulitzer/post_types_controller.rb