Class: StoriesController

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

Instance Method Summary collapse

Methods included from Wizard::Controller::Concerns::Paths

#next_wizard_path, #previous_wizard_path, #wizard_path

Methods included from Wizard::Controller::Concerns::Steps

#current_step?, #future_step?, #jump_to, #last_step?, #next_step, #next_step?, #past_step?, #previous_step, #previous_step?, #skip_step, #step, #wizard_resource_class_name, #wizard_step_per_state, #wizard_steps

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_repository_path, #voluntary_application_stylesheets

Methods included from Applicat::Mvc::Controller

included

Instance Method Details

#createObject



27
28
29
30
31
32
33
# File 'app/controllers/stories_controller.rb', line 27

def create
  if @story.initialization
    redirect_to edit_story_path(@story) and return
  else
    render_wizard
  end
end

#destroyObject



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

def destroy
  @story = Story.find(params[:id])
  @story.destroy
  redirect_to @story.project, notice: t('general.form.destroyed')
end

#editObject



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

def edit
  #if @story.tasks.none?
    #@story.tasks << @story.tasks.new
    #@story.tasks.first.errors.clear
  #end
  
  render_wizard
end

#indexObject



14
15
16
17
# File 'app/controllers/stories_controller.rb', line 14

def index
  parent = find_parent Story::PARENT_TYPES
  @stories = parent ? parent.stories : Story.all
end

#newObject



23
24
25
# File 'app/controllers/stories_controller.rb', line 23

def new
  render_wizard
end

#parentObject



73
74
75
# File 'app/controllers/stories_controller.rb', line 73

def parent
  @project
end

#resourceObject



65
66
67
68
69
# File 'app/controllers/stories_controller.rb', line 65

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

#resource=(value) ⇒ Object



71
# File 'app/controllers/stories_controller.rb', line 71

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

#showObject



19
20
21
# File 'app/controllers/stories_controller.rb', line 19

def show
  @comments = @story.comments
end

#updateObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/stories_controller.rb', line 44

def update
  @story.attributes = params[:story]
  success = params[:next_step] == '1' ? @story.send(step) : @story.save
  
  if success
    redirect_to(
      edit_story_path(@story), notice: t('general.form.successfully_updated')
    )
  else
    render_wizard
  end
  
  return
end