mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 18:29:52 +01:00
17 lines
514 B
Ruby
17 lines
514 B
Ruby
class Ajax::SubscriptionController < AjaxController
|
|
before_action :authenticate_user!
|
|
|
|
def subscribe
|
|
params.require :answer
|
|
@response[:status] = :okay
|
|
result = Subscription.subscribe(current_user, Answer.find(params[:answer]))
|
|
@response[:success] = result.present?
|
|
end
|
|
|
|
def unsubscribe
|
|
params.require :answer
|
|
@response[:status] = :okay
|
|
result = Subscription.unsubscribe(current_user, Answer.find(params[:answer]))
|
|
@response[:success] = result&.destroyed? || false
|
|
end
|
|
end
|