class FeatureModelMapsController < ApplicationController
  before_action :set_feature_model_map, only: %i[show edit update destroy]

  # GET /feature_model_maps or /feature_model_maps.json
  def index
    @feature_model_maps = FeatureModelMap.all.order(:created_at)
  end

  # GET /feature_model_maps/1 or /feature_model_maps/1.json
  def show; end

  # GET /feature_model_maps/new
  def new
    @feature_model_map = FeatureModelMap.new
  end

  # GET /feature_model_maps/1/edit
  def edit; end

  # POST /feature_model_maps or /feature_model_maps.json
  def create
    @feature_model_map = FeatureModelMap.new(feature_model_map_params)

    respond_to do |format|
      if @feature_model_map.save
        format.html { redirect_to feature_model_maps_path, notice: "Feature model map was successfully created." }
        format.json { render :show, status: :created, location: @feature_model_map }
      else
        format.html { render :new, status: :unprocessable_entity }
        format.json { render json: @feature_model_map.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /feature_model_maps/1 or /feature_model_maps/1.json
  def update
    respond_to do |format|
      if @feature_model_map.update(feature_model_map_params)
        format.html { redirect_to feature_model_maps_path, notice: "Feature model map was successfully updated." }
        format.json { render :show, status: :ok, location: @feature_model_map }
      else
        format.html { render :edit, status: :unprocessable_entity }
        format.json { render json: @feature_model_map.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /feature_model_maps/1 or /feature_model_maps/1.json
  def destroy
    @feature_model_map.destroy

    respond_to do |format|
      format.html { redirect_to feature_model_maps_url, notice: "Feature model map was successfully destroyed." }
      format.json { head :no_content }
    end
  end

  private

  # Use callbacks to share common setup or constraints between actions.
  def set_feature_model_map
    @feature_model_map = FeatureModelMap.find(params[:id])
  end

  # Only allow a list of trusted parameters through.
  def feature_model_map_params
    params.require(:feature_model_map).permit(:feature_name, :provider_model)
  end
end
