Slim down the Api::EventsController#index

This commit is contained in:
Petko Bordjukov 2015-10-08 01:46:21 +03:00
parent f056e5e50b
commit 82d44e79a7
2 changed files with 16 additions and 10 deletions

View File

@ -1,14 +1,8 @@
class Api::EventsController < Api::ApplicationController class Api::EventsController < Api::ApplicationController
include ::CurrentConferenceAssigning
before_filter :require_current_conference!
def index def index
@conference = find_conference @events = current_conference.events.includes(:participations)
@events = @conference.events.includes(:track, :event_type)
render json: @events, include: [:track, :event_type]
end
private
def find_conference
Conference.find params[:conference_id]
end end
end end

View File

@ -0,0 +1,12 @@
json.array! @events do |event|
json.id event.id
json.title event.title
json.subtitle event.subtitle
json.length event.length
json.language event.language
json.abstract event.abstract
json.description event.description
json.event_type_id event.event_type_id
json.track_id event.track_id
json.participant_user_ids event.participations.map(&:participant_id)
end