Class: Tomify::Api::Public::SubscriptionsController

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/tomify/api/public/subscriptions_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



2
3
4
5
6
7
8
9
# File 'app/controllers/tomify/api/public/subscriptions_controller.rb', line 2

def destroy
  subscription = Tomify.models.subscription.find_or_create_by(email: params[:subscription][:email])
  if subscription.update(active: false)
    render json: { type: :success, message: "You have been unsubscribed from #{setting(:name)}" }
  else
    render json: { type: :warning, message: "There was a problem unsubscribing you from #{setting(:name)}" }
  end
end