Class: ProjectsController

Inherits:
ApplicationController show all
Includes:
Applicat::Mvc::Controller::Resource
Defined in:
app/controllers/projects_controller.rb

Instance Method Summary collapse

Methods included from Applicat::Mvc::Controller::Resource

included

Methods inherited from ApplicationController

#current_ability

Methods included from Voluntary::V1::BaseController

#parent, #voluntary_application_javascripts, #voluntary_application_repository_path, #voluntary_application_stylesheets

Methods included from Applicat::Mvc::Controller

included

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/projects_controller.rb', line 25

def create
  @project = Project.new(params[:project])
  @project.user_id = current_user.id
  
  if @project.save
    redirect_to @project, notice: t('general.form.successfully_created')
  else
    render :new
  end
end

#destroyObject



47
48
49
50
# File 'app/controllers/projects_controller.rb', line 47

def destroy
  @project.destroy
  redirect_to projects_url, notice: t('general.form.destroyed')
end

#editObject



36
37
# File 'app/controllers/projects_controller.rb', line 36

def edit
end

#indexObject



10
11
12
13
# File 'app/controllers/projects_controller.rb', line 10

def index
  @parent = find_parent Project::PARENT_TYPES
  @projects = @parent ? @parent.projects.order(:name) : Project.order(:name)
end

#newObject



20
21
22
23
# File 'app/controllers/projects_controller.rb', line 20

def new
  @parent = find_parent Project::PARENT_TYPES
  @project = @parent ? @parent.projects.new : Project.new
end

#resourceObject



52
53
54
# File 'app/controllers/projects_controller.rb', line 52

def resource
  @project
end

#showObject



15
16
17
18
# File 'app/controllers/projects_controller.rb', line 15

def show
  @project = Project.includes(:areas, :comments).friendly.find(params[:id])
  @comments = @project.comments
end

#updateObject



39
40
41
42
43
44
45
# File 'app/controllers/projects_controller.rb', line 39

def update
  if @project.update_attributes(params[:project])
    redirect_to @project, notice: t('general.form.successfully_updated')
  else
    render :edit
  end
end