Class: Pulitzer::PartialsController
Defined Under Namespace
Classes: UpgradePartialVersion
Instance Method Summary
collapse
Instance Method Details
#create ⇒ Object
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
|
#destroy ⇒ Object
43
44
45
46
|
# File 'app/controllers/pulitzer/partials_controller.rb', line 43
def destroy
@partial.destroy
head :ok and return
end
|
#edit ⇒ Object
25
26
27
|
# File 'app/controllers/pulitzer/partials_controller.rb', line 25
def edit
render partial: 'form', locals: { partial: @partial }
end
|
#new ⇒ Object
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
|
#show ⇒ Object
21
22
23
|
# File 'app/controllers/pulitzer/partials_controller.rb', line 21
def show
render partial: 'show', locals: { partial: @partial }
end
|
#update ⇒ Object
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_all ⇒ Object
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 and return
end
|
#upgrade ⇒ Object
48
49
50
51
|
# File 'app/controllers/pulitzer/partials_controller.rb', line 48
def upgrade
@partial = UpgradePartialVersion.new(@partial).call
render partial: 'show', locals: { partial: @partial }
end
|