Sha256: 9185eb37b05f8ec413707215353eac341dd41f33f6d5e51a7293cb929cd94f8f

Contents?: true

Size: 920 Bytes

Versions: 8

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true
require_dependency 'c/application_controller'

module C
  class AdminController < ApplicationController
    check_authorization unless: :devise_controller?

    before_action :authenticate_user!
    before_action :current_user_id

    def edit
      ajax_form
    end

    def new
      ajax_form
    end

    private

    def current_ability
      @current_ability ||= ::C::Ability.new(current_user)
    end

    def ajax_form
      respond_to do |format|
        format.html
        format.js { render 'quick_edit' }
      end
    end

    def current_user_id
      # For the Authorable concern
      $user_id = current_user.id
    end

    def filter_and_paginate(collection, default_sort='id asc', per_page=30)
      @q = collection.ransack(params[:q])
      @q.sorts = default_sort if @q.sorts.empty?
      @q.result.paginate(page: params[:page], per_page: per_page)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cd2_catton_cms-1.1.35 app/controllers/c/admin_controller.rb
cd2_catton_cms-1.1.34 app/controllers/c/admin_controller.rb
cd2_catton_cms-1.1.33 app/controllers/c/admin_controller.rb
cd2_catton_cms-1.1.32 app/controllers/c/admin_controller.rb
cd2_catton_cms-1.1.31 app/controllers/c/admin_controller.rb
cd2_catton_cms-1.1.30 app/controllers/c/admin_controller.rb
cd2_catton_cms-1.1.20 app/controllers/c/admin_controller.rb
cd2_catton_cms-1.1.10 app/controllers/c/admin_controller.rb