1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/views/api/trainings/index.json.jbuilder
2016-07-13 18:15:14 +02:00

10 lines
390 B
Ruby

role = (current_user and current_user.is_admin?) ? 'admin' : 'user'
json.cache! [@trainings, role] do
json.array!(@trainings) do |training|
json.extract! training, :id, :name, :description, :machine_ids, :nb_total_places
json.training_image training.training_image.attachment.large.url if training.training_image
json.plan_ids training.plan_ids if role === 'admin'
end
end