From a9803853c02bcee8dd7473b3d1bd934c4f03ddba Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Sat, 17 Oct 2015 17:28:57 +0300 Subject: [PATCH] Change the api format to a set --- app/views/api/event_types/index.jbuilder | 19 ++++++++++--------- app/views/api/events/index.jbuilder | 23 ++++++++++++----------- app/views/api/halls/index.jbuilder | 6 +++++- app/views/api/slots/index.jbuilder | 6 +++++- app/views/api/speakers/index.jbuilder | 8 +++++--- app/views/api/tracks/index.jbuilder | 19 ++++++++++--------- 6 files changed, 47 insertions(+), 34 deletions(-) diff --git a/app/views/api/event_types/index.jbuilder b/app/views/api/event_types/index.jbuilder index 3848b38..8028866 100644 --- a/app/views/api/event_types/index.jbuilder +++ b/app/views/api/event_types/index.jbuilder @@ -1,13 +1,14 @@ -json.array! @event_types do |event_type| - json.extract! event_type, :id - json.name do - event_type.translations.each do |translation| - json.set! translation.locale, translation.name +@event_types.each do |event_type| + json.set! event_type.id do + json.name do + event_type.translations.each do |translation| + json.set! translation.locale, translation.name + end end - end - json.description do - event_type.translations.each do |translation| - json.set! translation.locale, translation.description + json.description do + event_type.translations.each do |translation| + json.set! translation.locale, translation.description + end end end end diff --git a/app/views/api/events/index.jbuilder b/app/views/api/events/index.jbuilder index 3bbf5e3..543b195 100644 --- a/app/views/api/events/index.jbuilder +++ b/app/views/api/events/index.jbuilder @@ -1,12 +1,13 @@ - 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) +@events.each do |event| + json.set! event.id do + 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 end diff --git a/app/views/api/halls/index.jbuilder b/app/views/api/halls/index.jbuilder index 0707f08..b57e36d 100644 --- a/app/views/api/halls/index.jbuilder +++ b/app/views/api/halls/index.jbuilder @@ -1 +1,5 @@ -json.array! @halls, :id, :name +@halls.each do |hall| + json.set! hall.id do + json.extract! hall, :name + end +end diff --git a/app/views/api/slots/index.jbuilder b/app/views/api/slots/index.jbuilder index 4cd9ba5..6068121 100644 --- a/app/views/api/slots/index.jbuilder +++ b/app/views/api/slots/index.jbuilder @@ -1 +1,5 @@ -json.array! @slots, :hall_id, :event_id, :starts_at, :ends_at +@slots.each do |slot| + json.set! slot.id do + json.extract! slot, :hall_id, :event_id, :starts_at, :ends_at + end +end diff --git a/app/views/api/speakers/index.jbuilder b/app/views/api/speakers/index.jbuilder index 427c242..f547474 100644 --- a/app/views/api/speakers/index.jbuilder +++ b/app/views/api/speakers/index.jbuilder @@ -1,4 +1,6 @@ -json.array! @speakers do |speaker| - json.extract! speaker, :user_id, :twitter, :github, :biography, :public_email, :organisation, :last_name, :first_name - json.picture speaker.picture.serializable_hash +@speakers.each do |speaker| + json.set! speaker.id do + json.extract! speaker, :twitter, :github, :biography, :public_email, :organisation, :last_name, :first_name + json.picture speaker.picture.serializable_hash + end end diff --git a/app/views/api/tracks/index.jbuilder b/app/views/api/tracks/index.jbuilder index 7fc65f9..a3aa9ee 100644 --- a/app/views/api/tracks/index.jbuilder +++ b/app/views/api/tracks/index.jbuilder @@ -1,13 +1,14 @@ -json.array! @tracks do |track| - json.extract! track, :id - json.name do - track.translations.each do |translation| - json.set! translation.locale, translation.name +@tracks.each do |track| + json.set! track.id do + json.name do + track.translations.each do |translation| + json.set! translation.locale, translation.name + end end - end - json.description do - track.translations.each do |translation| - json.set! translation.locale, translation.description + json.description do + track.translations.each do |translation| + json.set! translation.locale, translation.description + end end end end