Sha256: daea2d040d8dc36f1a52d0328f6fb1d7446aae448b86941b925d1c323a070cce

Contents?: true

Size: 534 Bytes

Versions: 1

Compression:

Stored size: 534 Bytes

Contents

module Devise
  module Models
    module Pinfirmable
      extend ActiveSupport::Concern
      included do
        before_create :generate_confirmation_token
        after_commit :send_confirmation_instructions, on: :create
      end

      protected

      def generate_confirmation_token
        pin = ""
        6.times { pin << SecureRandom.random_number(9).to_s }
        self.pinfirmable_pin = pin
      end

      def send_confirmation_instructions
        PinfirmableMailer.pin_email(self).deliver
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pinfirmable-0.1.0 lib/pinfirmable/models/pinfirmable.rb