Slim down the Api::EventsController#index
This commit is contained in:
parent
f056e5e50b
commit
82d44e79a7
|
@ -1,14 +1,8 @@
|
|||
class Api::EventsController < Api::ApplicationController
|
||||
include ::CurrentConferenceAssigning
|
||||
before_filter :require_current_conference!
|
||||
|
||||
def index
|
||||
@conference = find_conference
|
||||
@events = @conference.events.includes(:track, :event_type)
|
||||
|
||||
render json: @events, include: [:track, :event_type]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_conference
|
||||
Conference.find params[:conference_id]
|
||||
@events = current_conference.events.includes(:participations)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue