Sha256: ad0455b6740e3ff2dc3b3933be3860f2321f4fed0088ddc8e8195dfe922f103a

Contents?: true

Size: 1.06 KB

Versions: 11

Compression:

Stored size: 1.06 KB

Contents

module Alchemy
  module Custom
    module Model
      module Admin
        class BaseWithGlobalizeController < ::Alchemy::Custom::Model::Admin::BaseController


          around_action :switch_globalize_locale
          before_action :load_object, except: :index


          def index
            @query = base_class.ransack(params[:q])
            @objects = @query.result(distinct: true)
            @objects = @objects.accessible_by(current_ability)
            @total_objects = @objects
            @objects = @objects.page(params[:page]).
                per(params[:per_page] ||
                        (base_class::DEFAULT_PER_PAGE if base_class.const_defined? :DEFAULT_PER_PAGE) ||
                        25)
            instance_variable_set "@#{base_class.name.demodulize.underscore.downcase.pluralize}", @objects
          end



          private

          def switch_globalize_locale(&action)
            locale = Alchemy::Language.current.language_code.to_sym
            Globalize.with_locale(locale, &action)
          end


        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
alchemy-custom-model-3.2 app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb
alchemy-custom-model-3.1.5 app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb
alchemy-custom-model-3.1.4 app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb
alchemy-custom-model-3.1.3 app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb
alchemy-custom-model-3.1.2 app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb
alchemy-custom-model-3.1.1 app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb
alchemy-custom-model-3.1.0 app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb
alchemy-custom-model-2.2.2 app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb
alchemy-custom-model-3.0.0 app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb
alchemy-custom-model-2.2.1 app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb
alchemy-custom-model-2.2.0 app/controllers/alchemy/custom/model/admin/base_with_globalize_controller.rb