Sha256: 2f168e9bd17b19ba50786c241309272a01a12862663161f4a35adc7464fb4b76

Contents?: true

Size: 680 Bytes

Versions: 1

Compression:

Stored size: 680 Bytes

Contents

module Pageflow
  module QuotaVerification
    extend ActiveSupport::Concern

    included do
      rescue_from Quota::ExceededError do |exception|
        respond_to do |format|
          format.html do
            redirect_to :back, :alert => t('quotas.exceeded')
          end
          format.json do
            render(:status => :forbidden,
                   :json => {
                     :error_message => exception.message,
                     :quota_name => exception.quota_name
                   })
          end
        end
      end
    end

    protected

    def verify_quota!(name, account)
      Pageflow.config.quota.verify!(name, account)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pageflow-0.1.0 app/controllers/concerns/pageflow/quota_verification.rb