Class: Banal::BrainstormsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#choose_layout

Instance Method Details

#createObject

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



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

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

  respond_to do |format|
    if @banal_brainstorm.save
      format.html { redirect_to @banal_brainstorm, notice: 'Brainstorm was successfully created.' }
      format.json { render :show, 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



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

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



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

def edit
end

#indexObject

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



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

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



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

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



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

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

#showObject

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



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

def show
end

#updateObject

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



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

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