Class: Pulitzer::PartialsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @free_form_section = Pulitzer::FreeFormSection.find partial_params[:free_form_section_id]
  @partial = @free_form_section.partials.create partial_params
  if @partial && @partial.errors.empty?
    Pulitzer::CreatePartialContentElements.new(@partial).call
    render partial: 'show_wrapper', locals: { partial: @partial }
  else
    render partial: 'new', locals: {partial: @partial}
  end
end

#destroyObject



43
44
45
46
# File 'app/controllers/pulitzer/partials_controller.rb', line 43

def destroy
  @partial.destroy
  head :ok
end

#editObject



25
26
27
# File 'app/controllers/pulitzer/partials_controller.rb', line 25

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

#newObject



4
5
6
7
8
# File 'app/controllers/pulitzer/partials_controller.rb', line 4

def new
  @partial = Pulitzer::Partial.new(partial_params)
  @free_form_section = @partial.free_form_section
  render partial: 'new', locals: { partial: @partial }
end

#showObject



21
22
23
# File 'app/controllers/pulitzer/partials_controller.rb', line 21

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

#updateObject



29
30
31
32
# File 'app/controllers/pulitzer/partials_controller.rb', line 29

def update
  @partial.update partial_params
  render partial: 'show', locals: { partial: @partial }
end

#update_allObject



34
35
36
37
38
39
40
41
# File 'app/controllers/pulitzer/partials_controller.rb', line 34

def update_all
  partials = Pulitzer::Partial.find params[:partial]
  partials.each do |partial|
    new_sort_order = params[:partial].index(partial.id.to_s)
    partial.update_attribute(:sort_order, new_sort_order)
  end
  head :ok
end