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