Class: Dscf::Banking::DocumentsController
Instance Method Summary
collapse
#authorize_review_action!, #bypass_permissions_for_demo?, #pundit_user
#bypass_permissions_for_demo?, #pundit_user
Instance Method Details
#create ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/dscf/banking/documents_controller.rb', line 24
def create
document = @application.documents.build(model_params)
if document.save
document.files.attach(params[:document][:file]) if params[:document][:file].present?
render json: {
success: true,
data: DocumentSerializer.new(document).as_json
}, status: :created
else
render json: {
success: false,
error: "Failed to create document",
errors: document.errors.full_messages
}, status: :unprocessable_entity
end
end
|
#index ⇒ Object
8
9
10
11
12
13
14
|
# File 'app/controllers/dscf/banking/documents_controller.rb', line 8
def index
super do
documents = @application.documents
options = { each_serializer: DocumentSerializer }
[documents, options]
end
end
|
#show ⇒ Object
16
17
18
19
20
21
22
|
# File 'app/controllers/dscf/banking/documents_controller.rb', line 16
def show
super do
document = @application.documents.find(params[:id])
options = { serializer: DocumentSerializer }
[document, options]
end
end
|