mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-19 07:06:03 +01:00
17 lines
508 B
Ruby
17 lines
508 B
Ruby
class Ajax::SubscriptionController < AjaxController
|
|
before_action :authenticate_user!
|
|
|
|
def subscribe
|
|
params.require :answer
|
|
@response[:status] = :okay
|
|
state = Subscription.subscribe(current_user, Answer.find(params[:answer])).nil?
|
|
@response[:success] = state == false
|
|
end
|
|
|
|
def unsubscribe
|
|
params.require :answer
|
|
@response[:status] = :okay
|
|
state = Subscription.unsubscribe(current_user, Answer.find(params[:answer])).nil?
|
|
@response[:success] = state == false
|
|
end
|
|
end
|