mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-02-08 00:23:36 +01:00
19 lines
636 B
Ruby
19 lines
636 B
Ruby
class Ajax::SubscriptionController < AjaxController
|
|
before_action :authenticate_user!
|
|
|
|
def subscribe
|
|
params.require :answer
|
|
@response[:status] = 418
|
|
@response[:message] = I18n.t('messages.subscription.torpedo')
|
|
state = Subscription.subscribe(current_user, Answer.find(params[:answer])).nil?
|
|
@response[:success] = state == false
|
|
end
|
|
|
|
def unsubscribe
|
|
params.require :answer
|
|
@response[:status] = 418
|
|
@response[:message] = I18n.t('messages.subscription.torpedo')
|
|
state = Subscription.unsubscribe(current_user, Answer.find(params[:answer])).nil?
|
|
@response[:success] = state == false
|
|
end
|
|
end
|