Class: EgovUtils::PeopleController

Inherits:
ApplicationController show all
Defined in:
app/controllers/egov_utils/people_controller.rb

Instance Method Summary collapse

Instance Method Details

#addressesObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/egov_utils/people_controller.rb', line 25

def addresses
  addresses = Address.where(person_id: params[:person_id])

  render json: {
    results: addresses.map do |a|
      {
        id: a.id,
        text: a.to_s,
        street: a.street,
        number: a.number,
        postcode: a.postcode,
        city: a.city
      }
    end
  }
end

#indexObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/egov_utils/people_controller.rb', line 6

def index
  @people_schema = PersonSchema.new
  @people_schema.from_params(params)
  respond_to do |format|
    if params['_type'] == 'query'
      format.json{ render json: {
        results: @people_schema.entities.includes(:residence, :addresses).collect do |p|
            {id: p.id, text: p.to_s, residence: p.residence.to_s, addresses: p.addresses}
          end
      }}
    else
      format.json{ render json: @people_schema }
    end
  end
end

#showObject



22
23
# File 'app/controllers/egov_utils/people_controller.rb', line 22

def show
end