DeploymentsSerializer can serialize arrays properly

This commit is contained in:
Pawel Chojnacki 2017-04-24 21:34:21 +02:00
parent e1e0b763dc
commit e057ad975c

View file

@ -1,14 +1,13 @@
class Projects::DeploymentsController < Projects::ApplicationController
before_action :authorize_read_environment!
before_action :authorize_read_deployment!
def index
serializer = DeploymentSerializer.new(user: @current_user, project: project)
deployments = environment.deployments.reorder(created_at: :desc)
deployments = deployments.where('created_at > ?', params[:after].to_time) if params[:after]&.to_time
deployments = deployments.map { |deployment| serializer.represent(deployment) }
render json: { deployments: deployments }
render json: { deployments: DeploymentSerializer.new(user: @current_user, project: project)
.represent(deployments) }
end
private