Sha256: 1cb3703aeb4364c70a6c853c7fa6335f338d1b374cabe9c0af2a6c2ddb1cee47

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require_dependency "jobshop/application_controller"

module Jobshop
  class Welcome::ThingsController < ApplicationController
    respond_to :html

    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

    def index
      redirect_to new_welcome_things_path
    end

    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

    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

    private def thing_params
      params.require(:thing).permit(:identifier)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jobshop-0.0.131 app/controllers/jobshop/welcome/things_controller.rb
jobshop-0.0.127 app/controllers/jobshop/welcome/things_controller.rb