Skip to content

Commit

Permalink
divions/all endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
glartor committed Nov 28, 2024
1 parent 82075e7 commit 703f955
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/controllers/api/v1/divisions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ def index_with_address
render json: divisions.map { |division| format_division(division) }
end

def index_all
#seed_commons_id = Division.find_by(name: "Seed Commons").id
seed_commons_division_ids = Division.find_by(name: "Seed Commons").self_and_descendants.pluck(:id)
#divisions = Division.includes(address: [:country, :geo_state]).where(parent_id: seed_commons_id, public: true)
divisions = Division.includes(address: [:country, :geo_state]).where(parent_id: seed_commons_division_ids).order(name: :asc)
render json: divisions.map { |division| format_division(division) }
end

def index
divisions = [
{
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
delete 'address', on: :member, to: 'divisions#remove_address'
end
get 'divisions/with_address', to: 'divisions#index_with_address'
get 'divisions/all', to: 'divisions#index_all'

resources :loans, only: [:index]
resources :addresses
Expand Down

0 comments on commit 703f955

Please sign in to comment.