Class: Storytime::Subscription

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ScopedToSite
Defined in:
app/models/storytime/subscription.rb

Instance Method Summary collapse

Instance Method Details

#generate_tokenObject



14
15
16
17
18
19
# File 'app/models/storytime/subscription.rb', line 14

def generate_token
  key = Rails.application.secret_key_base
  digest = OpenSSL::Digest.new('sha1')

  self.token = OpenSSL::HMAC.hexdigest(digest, key, self.email)
end

#unsubscribe!Object



21
22
23
# File 'app/models/storytime/subscription.rb', line 21

def unsubscribe!
  update!(subscribed: false)
end