Class: Welcome::ThingsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/jobshop/welcome/things_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
# File 'app/controllers/jobshop/welcome/things_controller.rb', line 19

def create
  if @thing = current_team.things.create(thing_params)
    session[:thing_id] = @thing.id
    session[:next_onboard_path] = new_welcome_places_path
  end

  respond_with @thing, location: -> { new_welcome_places_path }
end

#indexObject



15
16
17
# File 'app/controllers/jobshop/welcome/things_controller.rb', line 15

def index
  redirect_to new_welcome_things_path
end

#newObject



7
8
9
10
11
12
13
# File 'app/controllers/jobshop/welcome/things_controller.rb', line 7

def new
  @thing = if session[:thing_id].present?
             current_team.things.find_by(id: session[:thing_id])
           end
  @thing ||= current_team.things.build
  respond_with(@thing)
end

#updateObject



28
29
30
31
32
33
34
35
36
# File 'app/controllers/jobshop/welcome/things_controller.rb', line 28

def update
  @thing = current_team.things.find(params[:id])
  if @thing.update(thing_params)
    session[:thing_id] = @thing.id
    respond_with @thing, location: -> { new_welcome_places_path }
  else
    render :new
  end
end