Class: Kidspire::Api::V1::EventsController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Kidspire::Api::V1::EventsController
- Defined in:
- app/controllers/kidspire/api/v1/events_controller.rb
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
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: (events) } end |
#show ⇒ Object
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 |