Sha256: 14b75b157164831e78aa4b44255ef1c4555dd652090ea3020dbe4ea0d239f71f

Contents?: true

Size: 1.31 KB

Versions: 21

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

class Admin::RedirectsController < Admin::BaseController
  before_action :set_redirect, only: [:edit, :update, :destroy]

  def index
    @redirects = Redirect.where(content_id: nil).order("id desc").page(params[:page]).
      per(this_blog.admin_display_elements)
    @redirect = Redirect.new
  end

  def edit
    @redirects = Redirect.where(content_id: nil).order("id desc").page(params[:page]).
      per(this_blog.admin_display_elements)
  end

  def create
    @redirect = this_blog.redirects.build(redirect_params)

    if @redirect.save
      redirect_to admin_redirects_url, notice: "Redirect was successfully created."
    else
      render :index
    end
  end

  def update
    if @redirect.update(redirect_params)
      redirect_to admin_redirects_url, notice: "Redirect was successfully updated."
    else
      render :edit
    end
  end

  def destroy
    @redirect.destroy
    redirect_to admin_redirects_url, notice: I18n.t("admin.redirects.destroy.success")
  end

  private

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

  # Never trust parameters from the scary internet, only allow the white list through.
  def redirect_params
    params.require(:redirect).permit(:from_path, :to_path)
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
HornsAndHooves-publify_core-10.5.0 app/controllers/admin/redirects_controller.rb
HornsAndHooves-publify_core-10.4.0 app/controllers/admin/redirects_controller.rb
HornsAndHooves-publify_core-10.3.0 app/controllers/admin/redirects_controller.rb
HornsAndHooves-publify_core-10.2.0 app/controllers/admin/redirects_controller.rb
publify_core-9.2.10 app/controllers/admin/redirects_controller.rb
HornsAndHooves-publify_core-10.1.1 app/controllers/admin/redirects_controller.rb
HornsAndHooves-publify_core-10.1.0 app/controllers/admin/redirects_controller.rb
HornsAndHooves-publify_core-10.0.3 app/controllers/admin/redirects_controller.rb
HornsAndHooves-publify_core-10.0.2 app/controllers/admin/redirects_controller.rb
HornsAndHooves-publify_core-10.0.1 app/controllers/admin/redirects_controller.rb
HornsAndHooves-publify_core-10.0.0 app/controllers/admin/redirects_controller.rb
publify_core-9.2.9 app/controllers/admin/redirects_controller.rb
publify_core-9.2.8 app/controllers/admin/redirects_controller.rb
publify_core-9.2.7 app/controllers/admin/redirects_controller.rb
publify_core-9.2.6 app/controllers/admin/redirects_controller.rb
publify_core-9.2.5 app/controllers/admin/redirects_controller.rb
publify_core-9.2.4 app/controllers/admin/redirects_controller.rb
publify_core-9.2.3 app/controllers/admin/redirects_controller.rb
publify_core-9.2.2 app/controllers/admin/redirects_controller.rb
publify_core-9.2.1 app/controllers/admin/redirects_controller.rb