class StaticPageTextsController < ApplicationController
  before_action :set_static_page_text, only: [:show, :edit, :update, :destroy]

  # GET /static_page_texts
  # GET /static_page_texts.json
  def index
    @static_page_texts = StaticPageText.all
  end

  # GET /static_page_texts/1
  # GET /static_page_texts/1.json
  def show
  end

  # GET /static_page_texts/new
  def new
    @static_page_text = StaticPageText.new
  end

  # GET /static_page_texts/1/edit
  def edit
  end

  # POST /static_page_texts
  # POST /static_page_texts.json
  def create
    @static_page_text = StaticPageText.new(static_page_text_params)

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

  # PATCH/PUT /static_page_texts/1
  # PATCH/PUT /static_page_texts/1.json
  def update
    respond_to do |format|
      if @static_page_text.update(static_page_text_params)
        if session.has_key? :return_to
          format.html { redirect_to session.delete(:return_to) }
        else
          format.html { redirect_to @static_page_text, notice: 'Static page text was successfully updated.' }
        end

        format.json { render :show, status: :ok, location: @static_page_text }
      else
        format.html { render :edit }
        format.json { render json: @static_page_text.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /static_page_texts/1
  # DELETE /static_page_texts/1.json
  def destroy
    @static_page_text.destroy
    respond_to do |format|
      format.html { redirect_to static_page_texts_url, notice: 'Static page text was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

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

    # Never trust parameters from the scary internet, only allow the white list through.
    def static_page_text_params
      params.require(:static_page_text).permit(:description, :text, :meta_description, :meta_keywords, :meta_title)
    end
end
