ensl.org/app/controllers/api/v1/teams_controller.rb
Chris Blanchard 970f5dd9cf Add teams api
2016-04-17 00:05:18 +01:00

23 lines
551 B
Ruby

class Api::V1::TeamsController < Api::V1::BaseController
def index
render json: Api::V1::UsersCollection.as_json
end
def show
@team = Team.find params[:id]
render json: {
id: @team.id,
name: @team.name,
logo: @team.logo,
members: @team.teamers.active.map do |m|
{
id: m.user.id,
username: m.user.username,
steamid: m.user.steamid
}
end
}
rescue ActiveRecord::RecordNotFound
raise ActionController::RoutingError.new("User Not Found")
end
end