Sha256: 7570e8a5c00e21cfb056cc63ede4d63cb182c942050ecd9689daa9215ab80383

Contents?: true

Size: 1.3 KB

Versions: 12

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

class Tramway::Admin::RecordsController < ::Tramway::Admin::ApplicationController
  def index
    scope = params[:scope].present? ? params[:scope] : :all
    records = model_class.active.order(id: :desc).send scope
    records = records.full_text_search params[:search] if params[:search]
    records = records.ransack(params[:filter]).result if params[:filter].present?
    @records = decorator_class.decorate records.page params[:page]
  end

  def show
    @record = decorator_class.decorate model_class.active.find params[:id]
  end

  def new
    @record_form = admin_form_class.new model_class.new
  end

  def create
    @record_form = admin_form_class.new model_class.new
    if @record_form.submit params[:record]
      redirect_to params[:redirect] || record_path(@record_form.model)
    else
      render :new
    end
  end

  def edit
    @record_form = admin_form_class.new model_class.active.find params[:id]
  end

  def update
    @record_form = admin_form_class.new model_class.active.find params[:id]
    if @record_form.submit params[:record]
      redirect_to params[:redirect] || record_path(@record_form.model)
    else
      render :edit
    end
  end

  def destroy
    record = model_class.active.find params[:id]
    record.remove
    redirect_to records_path
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
tramway-admin-1.19.0.2 app/controllers/tramway/admin/records_controller.rb
tramway-admin-1.19.0.1 app/controllers/tramway/admin/records_controller.rb
tramway-admin-1.19 app/controllers/tramway/admin/records_controller.rb
tramway-admin-1.18.4.4 app/controllers/tramway/admin/records_controller.rb
tramway-admin-1.18.4.3 app/controllers/tramway/admin/records_controller.rb
tramway-admin-1.18.4.2 app/controllers/tramway/admin/records_controller.rb
tramway-admin-1.18.4.1 app/controllers/tramway/admin/records_controller.rb
tramway-admin-1.18.4 app/controllers/tramway/admin/records_controller.rb
tramway-admin-1.18.3 app/controllers/tramway/admin/records_controller.rb
tramway-admin-1.18.2 app/controllers/tramway/admin/records_controller.rb
tramway-admin-1.18.1.1 app/controllers/tramway/admin/records_controller.rb
tramway-admin-1.18.1 app/controllers/tramway/admin/records_controller.rb