retrospring/app/controllers/ajax/subscription_controller.rb
Georg Gadinger e07d069c73 Refactor Ajax::*Controllers
Also removed the unused `Ajax::QuestionController#preview` method and
route
2020-04-28 20:28:00 +02:00

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