Class: Banal::BrainstormsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/banal/brainstorms_controller.rb

Overview

typed: false

Instance Method Summary collapse

Methods inherited from ApplicationController

#gdpr_compliance

Instance Method Details

#createObject

POST /banal/brainstorms POST /banal/brainstorms.json



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/banal/brainstorms_controller.rb', line 33

def create
  @banal_brainstorm = Banal::Brainstorm.new(banal_brainstorm_params)

  respond_to do |format|
    if @banal_brainstorm.save
      format.html { redirect_to banal_brainstorms_path + '#form', notice: 'Brainstorm was successfully created.' }
      format.json { render :index, status: :created, location: @banal_brainstorm }
    else
      format.html { render :new }
      format.json { render json: @banal_brainstorm.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /banal/brainstorms/1 DELETE /banal/brainstorms/1.json



77
78
79
80
81
82
83
# File 'app/controllers/banal/brainstorms_controller.rb', line 77

def destroy
  @banal_brainstorm.destroy
  respond_to do |format|
    format.html { redirect_to banal_brainstorms_url, notice: 'Brainstorm was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /banal/brainstorms/1/edit



28
29
# File 'app/controllers/banal/brainstorms_controller.rb', line 28

def edit
end

#indexObject

GET /banal/brainstorms GET /banal/brainstorms.json



7
8
9
10
11
12
13
14
15
# File 'app/controllers/banal/brainstorms_controller.rb', line 7

def index
  banal_brainstorms = Banal::Brainstorm

  if params[:only_killed]
    banal_brainstorms = banal_brainstorms.only_deleted
  end

  @banal_brainstorms = banal_brainstorms.all
end

#make_projectObject



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/banal/brainstorms_controller.rb', line 61

def make_project
  ActiveRecord::Base.transaction do
    project = Banal::Project.create!(
      @banal_brainstorm
       .attributes
       .except('idea', 'deleted_at', 'id')
       .merge({name: @banal_brainstorm.idea}))

    @banal_brainstorm.destroy_fully!

    redirect_to(banal_project_path(project.id))
  end
end

#newObject

GET /banal/brainstorms/new



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

def new
  @banal_brainstorm = Banal::Brainstorm.new
end

#showObject

GET /banal/brainstorms/1 GET /banal/brainstorms/1.json



19
20
# File 'app/controllers/banal/brainstorms_controller.rb', line 19

def show
end

#updateObject

PATCH/PUT /banal/brainstorms/1 PATCH/PUT /banal/brainstorms/1.json



49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/banal/brainstorms_controller.rb', line 49

def update
  respond_to do |format|
    if @banal_brainstorm.update(banal_brainstorm_params)
      format.html { redirect_to @banal_brainstorm, notice: 'Brainstorm was successfully updated.' }
      format.json { render :show, status: :ok, location: @banal_brainstorm }
    else
      format.html { render :edit }
      format.json { render json: @banal_brainstorm.errors, status: :unprocessable_entity }
    end
  end
end