Class: TasksController

Inherits:
ApplicationController show all
Includes:
Applicat::Mvc::Controller::Resource
Defined in:
app/controllers/tasks_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

#voluntary_application_javascripts, #voluntary_application_stylesheets

Methods included from Applicat::Mvc::Controller

included

Instance Method Details

#createObject



35
36
37
38
39
40
41
# File 'app/controllers/tasks_controller.rb', line 35

def create
  if @task.save
    redirect_to story_tasks_path(@story), notice: t('tasks.create.successful')
  else
    render 'new'
  end
end

#destroyObject



54
55
56
57
# File 'app/controllers/tasks_controller.rb', line 54

def destroy
  @task.destroy
  redirect_to story_tasks_path(@story), notice: t('general.form.destroyed')
end

#editObject



43
44
# File 'app/controllers/tasks_controller.rb', line 43

def edit
end

#indexObject



11
12
13
14
15
16
17
# File 'app/controllers/tasks_controller.rb', line 11

def index
  @story = Story.find(params[:story_id])
  @project = @story.project
  @tasks = @story.custom_tasks
  @tasks = @tasks.paginate(page: params[:page], per_page: 25)
  @twitter_sidenav_level = 5
end

#newObject



32
33
# File 'app/controllers/tasks_controller.rb', line 32

def new
end

#parentObject



68
69
70
# File 'app/controllers/tasks_controller.rb', line 68

def parent
  @story
end

#resourceObject



59
60
61
62
63
64
# File 'app/controllers/tasks_controller.rb', line 59

def resource
  @task = Task.find(params[:id]) unless @task || !params[:id].present?
  @story = @task.story unless @story || !@task
  @project = @story.project
  @task
end

#resource=(value) ⇒ Object



66
# File 'app/controllers/tasks_controller.rb', line 66

def resource=(value); @task = value; end

#showObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/tasks_controller.rb', line 19

def show
  @comments = @task.comments
  @hide_sidebar = true
  
  begin
    raise NotImplementedError if @project.product_id.blank?
    
    render "products/types/#{@project.product.class.name.split('Product::').last.tableize.singularize}/tasks/show"
  rescue NotImplementedError, ActionView::MissingTemplate
    render 'show'
  end
end

#updateObject



46
47
48
49
50
51
52
# File 'app/controllers/tasks_controller.rb', line 46

def update
  if @task.update(params[:task])
    redirect_to(
      edit_task_path(@task), notice: t('tasks.update.successful')
    )
  end
end