Sha256: 2f66786c64b68a799ea426e9b185c9ae3415afb01d4b7cf292150249ff3a9dc5

Contents?: true

Size: 995 Bytes

Versions: 2

Compression:

Stored size: 995 Bytes

Contents

require_dependency "jobshop/application_controller"

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

    def new
      @place = if session[:place_id].present?
                 current_team.places.find_by(id: session[:place_id])
               end
      @place ||= current_team.places.build
      respond_with(@place)
    end

    def index
      redirect_to new_welcome_places_path
    end

    def create
      if @place = current_team.places.create(place_params)
        session[:place_id] = @place.id
        session[:next_onboard_path] = "/"
      end

      respond_with @place, location: -> { "/" }
    end

    def update
      @place = current_team.places.find(params[:id])
      if @place.update(place_params)
        session[:place_id] = @place.id
        respond_with @place, location: -> { "/" }
      else
        render :new
      end
    end

    private def place_params
      params.require(:place).permit(:name)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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