Sha256: 6007acb394eab52d6b32ce7b1e3033288becbcce737b74faf3fdb2340192c3b1

Contents?: true

Size: 1.11 KB

Versions: 18

Compression:

Stored size: 1.11 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
  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

18 entries across 18 versions & 1 rubygems

Version Path
pulitzer-0.15.12 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.11 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.10 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.9 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.8 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.7 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.6 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.5 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.4 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.3 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.2 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.1 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.15.0 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.14.4 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.14.3 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.14.2 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.14.1 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.14.0 app/controllers/pulitzer/content_elements_controller.rb