1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

use slug in traning show url

This commit is contained in:
Sylvain 2016-09-27 16:00:22 +02:00
parent c27c4372b0
commit e48bb88f1f
3 changed files with 4 additions and 4 deletions

View File

@ -12,13 +12,13 @@ Application.Controllers.controller "TrainingsController", ['$scope', '$state', '
# Callback for the 'reserve' button # Callback for the 'reserve' button
## ##
$scope.reserveTraining = (training, event) -> $scope.reserveTraining = (training, event) ->
$state.go('app.logged.trainings_reserve', {id: training.id}) $state.go('app.logged.trainings_reserve', {id: training.slug})
## ##
# Callback for the 'show' button # Callback for the 'show' button
## ##
$scope.showTraining = (training) -> $scope.showTraining = (training) ->
$state.go('app.public.training_show', {id: training.id}) $state.go('app.public.training_show', {id: training.slug})
] ]

View File

@ -17,7 +17,7 @@ class API::TrainingsController < API::ApiController
end end
def show def show
@training = Training.find(params[:id]) @training = Training.friendly.find(params[:id])
end end
def create def create

View File

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