Sha256: 16dee4816fad54ec62ad8590fc8d714cf78f987958a95e41dfea5dad34b86ae1

Contents?: true

Size: 1.12 KB

Versions: 19

Compression:

Stored size: 1.12 KB

Contents

class Pulitzer::ContentElementsController < Pulitzer::ApplicationController
  before_action :set_content_element, only: [:show, :edit, :update]

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

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

  def update
    Update.new(@content_element, content_element_params).call
    if @content_element.errors.empty?
      render partial: 'show', locals: { content_element: @content_element }
    else
      render partial: 'form', locals: { content_element: @content_element }, status: :conflict
    end
  end

  def update_all
    content_elements = Pulitzer::ContentElement.find params[:content_element]
    content_elements.each do |ce|
      new_sort_order = params[:content_element].index(ce.id.to_s)
      ce.update_attribute(:sort_order, new_sort_order)
    end
    head :ok and return
  end

  protected

  def content_element_params
    params[:content_element].nil? ? {} : params[:content_element].permit!
  end

  def set_content_element
    @content_element = Pulitzer::ContentElement.find(params[:id])
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pulitzer-0.15.31 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.30 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.29 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.28 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.27 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.26 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.25 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.24 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.23 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.22 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.21 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.20 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.19 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.18 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.17 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.16 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.15 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.14 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.13 app/controllers/pulitzer/content_elements_controller.rb