diff --git a/app/controllers/api/application_controller.rb b/app/controllers/api/application_controller.rb new file mode 100644 index 0000000..b9568e7 --- /dev/null +++ b/app/controllers/api/application_controller.rb @@ -0,0 +1,2 @@ +class Api::ApplicationController < ::ApplicationController +end diff --git a/app/controllers/api/events_controller.rb b/app/controllers/api/events_controller.rb new file mode 100644 index 0000000..4ae04b2 --- /dev/null +++ b/app/controllers/api/events_controller.rb @@ -0,0 +1,14 @@ +class Api::EventsController < Api::ApplicationController + def index + @conference = find_conference + @events = @conference.events.includes(:track) + + render json: @events, include: :track + end + + private + + def find_conference + Conference.find params[:conference_id] + end +end diff --git a/config/routes.rb b/config/routes.rb index 02ca330..97b66fb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,12 @@ Rails.application.routes.draw do end end + namespace :api do + resources :conferences, only: [] do + resources :events, only: :index + end + end + namespace :management do root to: 'home#index'