Sha256: 368f17cb463fc08df8e50ef816ce6e0c7995e086bb79e8f40495f0f45f6abac8

Contents?: true

Size: 1.16 KB

Versions: 13

Compression:

Stored size: 1.16 KB

Contents

class Backend::TagsController < Backend::BaseController
  include Concerns::PaginationController

  before_action :find_model, only: [:show, :edit, :update, :destroy]
  before_action -> { breadcrumb.add t('b.tags'), backend_tags_path }

  def index
    @search = Tag.ransack params[:q]
    @tags = @search.result(distinct: true).order(:name).page(page_number).per_page(15)
  end

  def show
    redirect_to edit_backend_tag_path(@tag)
  end

  def new
    @tag = Tag.new
  end

  def create
    @tag = Tag.new(allowed_params)

    if @tag.save
      redirect_to backend_tags_path, notice: translate_notice(:added, :tag)
    else
      render :new
    end
  end

  def destroy
    @tag.destroy
    redirect_to backend_tags_path, notice: translate_notice(:deleted, :tag)
  end

  def update
    if @tag.update_attributes allowed_params
      redirect_to backend_tags_path, notice: translate_notice(:edited, :tag)
    else
      render :edit
    end
  end

  private

  def allowed_params
    params.require(:tag).permit(
      :locale, :name, :seo_slug, :seo_title, :seo_description, :seo_keywords,
      :seo_custom
    )
  end

  def find_model
    @tag = Tag.find params[:id]
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
udongo-7.9.0 app/controllers/backend/tags_controller.rb
udongo-7.8.1 app/controllers/backend/tags_controller.rb
udongo-7.8.0 app/controllers/backend/tags_controller.rb
udongo-7.7.2 app/controllers/backend/tags_controller.rb
udongo-7.7.1 app/controllers/backend/tags_controller.rb
udongo-7.7.0 app/controllers/backend/tags_controller.rb
udongo-7.6.2 app/controllers/backend/tags_controller.rb
udongo-7.6.1 app/controllers/backend/tags_controller.rb
udongo-7.6.0 app/controllers/backend/tags_controller.rb
udongo-7.5.1 app/controllers/backend/tags_controller.rb
udongo-7.5.0 app/controllers/backend/tags_controller.rb
udongo-7.4.2 app/controllers/backend/tags_controller.rb
udongo-7.4.1 app/controllers/backend/tags_controller.rb