Sha256: f8951a10f08fdec34b618f899858acbf8e6671d449366fdd9ed95709a87e417c
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
class Comfy::Admin::Archive::IndicesController < Comfy::Admin::Cms::BaseController before_action :build_index, only: %i[new create] before_action :load_index, only: %i[edit update destroy] before_action :authorize def index return redirect_to action: :new if @site.archive_indices.count.zero? indices_scope = @site.archive_indices @indices = comfy_paginate(indices_scope) end def new render end def create @index.save! flash[:success] = t(".created") redirect_to action: :edit, id: @index rescue ActiveRecord::RecordInvalid flash.now[:danger] = t(".create_failure") render action: :new end def edit render end def update @index.update_attributes!(index_params) flash[:success] = t(".updated") redirect_to action: :edit, id: @index rescue ActiveRecord::RecordInvalid flash.now[:danger] = t(".update_failure") render action: :edit end def destroy @index.destroy flash[:success] = t(".deleted") redirect_to action: :index end protected def load_index @index = @site.archive_indices.find(params[:id]) rescue ActiveRecord::RecordNotFound flash[:danger] = t(".not_found") redirect_to action: :index end def build_index @index = @site.archive_indices.new(index_params) end def index_params params.fetch(:index, {}).permit! end end
Version data entries
3 entries across 3 versions & 1 rubygems