Class: Dune::Api::V1::ProjectsController

Inherits:
BaseController
  • Object
show all
Includes:
PaginatedController
Defined in:
app/controllers/dune/api/v1/projects_controller.rb

Constant Summary

Constants inherited from BaseController

BaseController::MODULES

Instance Method Summary collapse

Methods included from PaginatedController

#respond_with_pagination

Methods inherited from BaseController

#access_token, #check_authorization!, #current_user, #handle_forbidden, #handle_unauthorized, #require_admin!

Instance Method Details

#destroyObject



30
31
32
33
34
35
36
# File 'app/controllers/dune/api/v1/projects_controller.rb', line 30

def destroy
  project = Project.find(params[:id])
  authorize project

  project.push_to_trash!
  head :no_content
end

#indexObject



14
15
16
# File 'app/controllers/dune/api/v1/projects_controller.rb', line 14

def index
  respond_with_pagination collection
end

#showObject



18
19
20
21
22
# File 'app/controllers/dune/api/v1/projects_controller.rb', line 18

def show
  project = ::Project.find(params[:id])
  authorize project
  respond_with project, serializer: Dune::Api::ProjectSerializer
end

#updateObject



24
25
26
27
28
# File 'app/controllers/dune/api/v1/projects_controller.rb', line 24

def update
  @project = Project.find(params[:id])
  authorize @project
  respond_with Project.update(params[:id], permitted_params)
end