-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdeclaration_controller.rb
More file actions
32 lines (27 loc) · 992 Bytes
/
declaration_controller.rb
File metadata and controls
32 lines (27 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module Forms
class DeclarationController < ApplicationController
after_action :verify_authorized
def new
authorize current_form, :can_view_form?
@declaration_input = DeclarationInput.new(form: current_form).assign_form_values
end
def create
authorize current_form, :can_view_form?
@declaration_input = DeclarationInput.new(**declaration_input_params)
if @declaration_input.submit
success_message = if @declaration_input.mark_complete == "true"
t("banner.success.form.declaration_saved_and_completed")
else
t("banner.success.form.declaration_saved")
end
redirect_to form_path(@declaration_input.form), success: success_message
else
render :new
end
end
private
def declaration_input_params
params.require(:forms_declaration_input).permit(:declaration_text, :mark_complete).merge(form: current_form)
end
end
end