Sha256: 925488abfe14fbbaa6ba0a47005484e289dd433bd2d6d15c1337ea318a6364d0

Contents?: true

Size: 989 Bytes

Versions: 16

Compression:

Stored size: 989 Bytes

Contents

class Pulitzer::ContentElementsController < Pulitzer::ApplicationController
  before_filter :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
    @content_element.update content_element_params
    render partial: 'show', locals: { content_element: @content_element }
  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
    render nothing: true
  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

16 entries across 16 versions & 1 rubygems

Version Path
pulitzer-0.12.5 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.12.4 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.12.3 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.12.2 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.12.1 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.12.0 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.11.3 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.11.2 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.11.1 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.11.0 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.10.3 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.10.2 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.10.1 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.10.0 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.5.14 app/controllers/pulitzer/content_elements_controller.rb
pulitzer-0.5.13 app/controllers/pulitzer/content_elements_controller.rb