Class: Dscf::Core::DocumentsController

Inherits:
ApplicationController show all
Includes:
Common
Defined in:
app/controllers/dscf/core/documents_controller.rb

Instance Method Summary collapse

Methods included from Common

#show, #update

Methods included from Authorizable

#authorize, #authorize_action!, #policy_scope, #pundit_user

Methods included from Filterable

#filter_records

Methods included from JsonResponse

#render_error, #render_success, #serialize

Methods included from Pagination

#default_per_page, #order_by, #order_direction, #page_no, #paginate, #paginate_offset, #pagination_links, #per_page

Methods included from TokenAuthenticatable

#require_valid_refresh_token, #validate_device_consistency, #validate_token_expiry

Methods included from Authenticatable

#authenticate_user, #authenticate_user!, #current_user, #refresh_token, #sign_in, #sign_out

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/dscf/core/documents_controller.rb', line 13

def create
  super do
    business = Business.find(params[:business_id])
    doc = business.documents.new(document_type: :business_license)
    if params[:document] && params[:document][:file].present?
      doc.files.attach(params[:document][:file])
    end
    doc
  end
end

#indexObject



6
7
8
9
10
11
# File 'app/controllers/dscf/core/documents_controller.rb', line 6

def index
  super do
    business = Business.find(params[:business_id])
    business.documents
  end
end