Sha256: 07ea1cb96c66634a2b4ddf0561a9e2792615a9428a086ffa86064ac99fd72cba

Contents?: true

Size: 1.09 KB

Versions: 24

Compression:

Stored size: 1.09 KB

Contents

module KepplerLanguages
  module Concerns
    # Concern con la configuracion de parametros de los formulario
    module Commons
      extend ActiveSupport::Concern

      included do
        before_action :paginator_params
        before_action :set_setting
      end

      private

      def paginator_params
        @search_field = model.search_field if listing?
        @query = params[:search] unless params[:search].blank?
        @current_page = params[:page] unless params[:page].blank?
      end

      def set_setting
        @setting = Setting.first
      end

      def module_name
        self.class.to_s.split('::').first.constantize
      end

      # Get submit key to redirect, only [:create, :update]
      def redirect(object, commit)
        if commit.key?('_save')
          redirect_to(request.path.split('/')[1..-2].map(&:to_sym).push(object), notice: actions_messages(object))
        elsif commit.key?('_add_other')
          redirect_to(
            send("new_admin_#{underscore(object)}_path"),
            notice: actions_messages(object)
          )
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
keppler-2.1.22 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.21 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.20 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.19 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.18 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.17 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.16 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.15 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.14 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.13 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.12 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.11 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.10 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.9 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.8 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.7 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.6 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.5 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.4 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb
keppler-2.1.3 installer/core/rockets/keppler_languages/app/controllers/keppler_languages/concerns/commons.rb