Class: Pulitzer::ContentElementsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Pulitzer::ContentElementsController
- Defined in:
- app/controllers/pulitzer/content_elements_controller.rb
Defined Under Namespace
Classes: Update
Instance Method Summary collapse
Instance Method Details
#edit ⇒ Object
8 9 10 |
# File 'app/controllers/pulitzer/content_elements_controller.rb', line 8 def edit render partial: 'form', locals: { content_element: @content_element } end |
#show ⇒ Object
4 5 6 |
# File 'app/controllers/pulitzer/content_elements_controller.rb', line 4 def show render partial: 'show', locals: { content_element: @content_element } end |
#update ⇒ Object
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_all ⇒ Object
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 |