class Settings::LookupsController < ApplicationController
  before_action :set_settings_lookup, only: [:show, :edit, :update, :destroy]

  # GET /settings/lookups
  # GET /settings/lookups.json
  def index
    @settings_lookups = Lookup.all
  end

  # GET /settings/lookups/1
  # GET /settings/lookups/1.json
  def show
  end

  # GET /settings/lookups/new
  def new
    @settings_lookup = Lookup.new
  end

  # GET /settings/lookups/1/edit
  def edit
  end

  # POST /settings/lookups
  # POST /settings/lookups.json
  def create
    @settings_lookup = Lookup.new(settings_lookup_params)

    respond_to do |format|
      if @settings_lookup.save
        format.html { redirect_to @settings_lookup, notice: 'Lookup was successfully created.' }
        format.json { render :show, status: :created, location: @settings_lookup }
      else
        format.html { render :new }
        format.json { render json: @settings_lookup.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /settings/lookups/1
  # PATCH/PUT /settings/lookups/1.json
  def update
    respond_to do |format|
      if @settings_lookup.update(settings_lookup_params)
        format.html { redirect_to @settings_lookup, notice: 'Lookup was successfully updated.' }
        format.json { render :show, status: :ok, location: @settings_lookup }
      else
        format.html { render :edit }
        format.json { render json: @settings_lookup.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /settings/lookups/1
  # DELETE /settings/lookups/1.json
  def destroy
    @settings_lookup.destroy
    respond_to do |format|
      format.html { redirect_to settings_lookups_url, notice: 'Lookup was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

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

    # Never trust parameters from the scary internet, only allow the white list through.
    def settings_lookup_params
      params.require(:lookup).permit(:lookup_type, :name, :value)
    end
end
