Sha256: 87637a82599a8c281ea49c790f51277ce623294583af066d70029fae05eb1569

Contents?: true

Size: 900 Bytes

Versions: 4

Compression:

Stored size: 900 Bytes

Contents

module Voluntary
  module Api
    module V1
      class OrganizationsController < ActionController::Base
        include Voluntary::V1::BaseController
       
        respond_to :json
        
        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
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voluntary-0.7.1 app/controllers/voluntary/api/v1/organizations_controller.rb
voluntary-0.7.0 app/controllers/voluntary/api/v1/organizations_controller.rb
voluntary-0.6.0 app/controllers/voluntary/api/v1/organizations_controller.rb
voluntary-0.5.2 app/controllers/voluntary/api/v1/organizations_controller.rb