Class: Nuntius::SubscribersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/nuntius/subscribers_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject

skip_before_action :authenticate_user!, only: %i[show destroy]



9
10
11
12
13
14
15
16
17
# File 'app/controllers/nuntius/subscribers_controller.rb', line 9

def show
  @subscriber = Nuntius::Subscriber.find_by(id: params[:id])
  if @subscriber
    @list = @subscriber.list
  else
    flash[:notice] = "Subscription not found."
    redirect_to root_path, status: :see_other
  end
end

#subscribeObject



19
20
21
22
23
24
# File 'app/controllers/nuntius/subscribers_controller.rb', line 19

def subscribe
  @subscriber = Nuntius::Subscriber.find(params[:id])
  @subscriber.update(unsubscribed_at: nil)
  flash[:notice] = "Subscription has been restored."
  redirect_to nuntius.subscriber_path(@subscriber), status: :see_other
end

#unsubscribeObject



26
27
28
29
30
31
# File 'app/controllers/nuntius/subscribers_controller.rb', line 26

def unsubscribe
  @subscriber = Nuntius::Subscriber.find(params[:id])
  @subscriber.touch(:unsubscribed_at)
  flash[:notice] = "Subscription has been removed."
  redirect_to nuntius.subscriber_path(@subscriber), status: :see_other
end