Class: MailyHerald::TokensController

Inherits:
ApplicationController show all
Defined in:
app/controllers/maily_herald/tokens_controller.rb

Instance Method Summary collapse

Instance Method Details

#getObject



3
4
5
6
7
8
9
# File 'app/controllers/maily_herald/tokens_controller.rb', line 3

def get
  @subscription = MailyHerald::Subscription.find_by_token(params[:token])
  @subscription.try(:deactivate!)

  redirect_to MailyHerald.token_redirect.try(:call, self, @subscription) || "/", 
    notice: @subscription ? t('maily_herald.subscription.deactivated') : t('maily_herald.subscription.undefined_token')
end