Class: Pulitzer::ContentElementsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/pulitzer/content_elements_controller.rb

Defined Under Namespace

Classes: Update

Instance Method Summary collapse

Instance Method Details

#editObject



8
9
10
# File 'app/controllers/pulitzer/content_elements_controller.rb', line 8

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

#showObject



4
5
6
# File 'app/controllers/pulitzer/content_elements_controller.rb', line 4

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

#updateObject



12
13
14
15
16
17
18
19
# File 'app/controllers/pulitzer/content_elements_controller.rb', line 12

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

#update_allObject



21
22
23
24
25
26
27
28
# File 'app/controllers/pulitzer/content_elements_controller.rb', line 21

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