Sha256: ec4d63c38cc8c7db0e14ded74913b22bb71df752aa7b397219ecc48e2e351a58

Contents?: true

Size: 1.24 KB

Versions: 33

Compression:

Stored size: 1.24 KB

Contents

class EmployeesController < ApplicationController
  before_action :set_employee, only: [:show, :edit, :update, :destroy]

  # GET /employees
  def index
    @employees = Employee.all
  end

  # GET /employees/1
  def show
  end

  # GET /employees/new
  def new
    @employee = Employee.new
  end

  # GET /employees/1/edit
  def edit
  end

  # POST /employees
  def create
    @employee = Employee.new(employee_params)

    if @employee.save
      redirect_to @employee, notice: 'Employee was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /employees/1
  def update
    if @employee.update(employee_params)
      redirect_to @employee, notice: 'Employee was successfully updated.'
    else
      render :edit
    end
  end

  # DELETE /employees/1
  def destroy
    @employee.destroy
    redirect_to employees_url, notice: 'Employee was successfully destroyed.'
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_employee
      @employee = Employee.find(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def employee_params
      params.require(:employee).permit(:name, :dob_dd, :dob_mm, :dob_yyyy, :joined_dd, :joined_mm, :joined_yyyy)
    end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
gov_uk_date_fields-4.2.0 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-3.2.0 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-3.2.0.rc3 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-3.2.0.rc2 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-3.2.0.rc1 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-4.1.0 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-4.0.1 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-4.0.0 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-3.1.0 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-3.0.0 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-2.2.0 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-2.1.1 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-2.1.0 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-2.0.3 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-2.0.2 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-1.2.3 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-1.2.2 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-1.2.1 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-1.2.0 test/dummy/app/controllers/employees_controller.rb
gov_uk_date_fields-1.1.0 test/dummy/app/controllers/employees_controller.rb