Class: Mailkick::SubscriptionsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/mailkick/subscriptions_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



8
9
# File 'app/controllers/mailkick/subscriptions_controller.rb', line 8

def show
end

#subscribeObject



27
28
29
30
31
# File 'app/controllers/mailkick/subscriptions_controller.rb', line 27

def subscribe
  subscription.first_or_create!

  redirect_to subscription_path(params[:id])
end

#unsubscribeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/mailkick/subscriptions_controller.rb', line 11

def unsubscribe
  defer = Mailkick.confirm_unsubscribe && request.get? && !params[:confirmed]

  subscription.delete_all unless defer

  if request.post? && params["List-Unsubscribe"] == "One-Click"
    # must not redirect according to RFC 8058
    # could render show action instead
    render plain: "Unsubscribe successful"
  elsif defer
    render :show
  else
    redirect_to subscription_path(params[:id])
  end
end