- Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathsubscribers_controller.rb
29 lines (25 loc) · 906 Bytes
/
subscribers_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
classSubscribersController < ApplicationController
# TODO: shouldn't need this, not sure why X-CSRF-Token header isn't working
skip_before_action:verify_authenticity_token
before_action:require_login,only: [:create,:destroy,:mute]
defcreate
@protip=Protip.find(params[:protip_id])
@protip.subscribe!(current_user)
renderjson: @protip,root: false
end
defdestroy
@protip=Protip.find(params[:protip_id])
@protip.unsubscribe!(current_user)
renderjson: @protip,root: false
end
defmute
@protip=Protip.find_by_public_id!(params[:protip_id])
ifparams[:signature] != current_user.unsubscribe_signature
flash[:notice]="Unsubscribe link is no longer valid"
else
@protip.unsubscribe!(current_user)
flash[:notice]="You will no longer receive new comment emails"
end
redirect_toseo_protip_path(@protip)
end
end