Class: Voluntary::Api::V1::OrganizationsController

Inherits:
ActionController::Base
  • Object
show all
Includes:
V1::BaseController
Defined in:
app/controllers/voluntary/api/v1/organizations_controller.rb

Instance Method Summary collapse

Methods included from V1::BaseController

#parent, #voluntary_application_javascripts, #voluntary_application_stylesheets

Instance Method Details

#indexObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/voluntary/api/v1/organizations_controller.rb', line 9

def index
  options = {}

  collection = Organization.order('name')
  collection = collection.where(user_id: params[:user_id]) if params[:user_id].present?
  options[:json] = collection.paginate(page: params[:page], per_page: 100)
  
  options[:meta] = { 
    pagination: {
      total_pages: options[:json].total_pages, current_page: options[:json].current_page,
      previous_page: options[:json].previous_page, next_page: options[:json].next_page
    }
  }
  
  respond_with do |format|
    format.json { render options }
  end
end