Sha256: 29e1a257783e4e01912431b48ba4cad0e7f6fbad4830b4083773c739f94cd7e5

Contents?: true

Size: 1.27 KB

Versions: 7

Compression:

Stored size: 1.27 KB

Contents

class Pulitzer::PostTypeContentElementTypesController < Pulitzer::ApplicationController
  before_action :get_ptcet, only: [:show, :edit, :update, :destroy]

  def new
    @post_type = Pulitzer::PostType.find(params[:post_type_id])
    @ptcet = @post_type.post_type_content_element_types.build
    render partial: 'new', locals: {ptcet: @ptcet}
  end

  def create
    @post_type = Pulitzer::PostType.find(ptcet_params[:post_type_id])
    @ptcet = @post_type.post_type_content_element_types.create(ptcet_params)
    Pulitzer::CreatePostTypeContentElements.new(@ptcet).call
    render partial: 'show_wrapper', locals: {ptcet: @ptcet}
  end

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

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

  def update
    old_label = @ptcet.label
    @ptcet.update_attributes(ptcet_params)
    Pulitzer::UpdatePostTypeContentElements.new(@ptcet, old_label).call
    render partial: 'show', locals: {ptcet: @ptcet}
  end

  def destroy
    @ptcet.destroy
    Pulitzer::DestroyPostTypeContentElements.new(@ptcet).call
    head :ok
  end

  protected

  def get_ptcet
    @ptcet = Pulitzer::PostTypeContentElementType.find(params[:id])
  end

  def ptcet_params
    params[:post_type_content_element_type].permit!
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pulitzer-0.14.4 app/controllers/pulitzer/post_type_content_element_types_controller.rb
pulitzer-0.14.3 app/controllers/pulitzer/post_type_content_element_types_controller.rb
pulitzer-0.14.2 app/controllers/pulitzer/post_type_content_element_types_controller.rb
pulitzer-0.14.1 app/controllers/pulitzer/post_type_content_element_types_controller.rb
pulitzer-0.14.0 app/controllers/pulitzer/post_type_content_element_types_controller.rb
pulitzer-0.13.1 app/controllers/pulitzer/post_type_content_element_types_controller.rb
pulitzer-0.13.0 app/controllers/pulitzer/post_type_content_element_types_controller.rb