Class: Kidspire::Api::V1::EventsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/kidspire/api/v1/events_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



8
9
10
11
12
13
14
# File 'app/controllers/kidspire/api/v1/events_controller.rb', line 8

def index
  events = Event.upcoming.page(params[:page]).per(params[:per_page] || 20)
  render json: {
    events: JSON.parse(EventBlueprint.render(events)),
    meta:   pagination_meta(events)
  }
end

#showObject



16
17
18
19
20
21
# File 'app/controllers/kidspire/api/v1/events_controller.rb', line 16

def show
  event = Event.find(params[:id])
  render json: EventBlueprint.render(event, view: :detail)
rescue ActiveRecord::RecordNotFound
  render json: { error: "Event not found", code: "not_found" }, status: :not_found
end