Retrospring/app/controllers/ajax/subscription_controller.rb

20 lines
636 B
Ruby
Raw Normal View History

class Ajax::SubscriptionController < AjaxController
2020-04-18 16:45:50 -07:00
before_action :authenticate_user!
2015-04-20 18:12:11 -07:00
def subscribe
params.require :answer
@response[:status] = 418
@response[:message] = I18n.t('messages.subscription.torpedo')
2015-04-20 18:12:11 -07:00
state = Subscription.subscribe(current_user, Answer.find(params[:answer])).nil?
@response[:success] = state == false
2015-04-20 18:12:11 -07:00
end
def unsubscribe
params.require :answer
@response[:status] = 418
@response[:message] = I18n.t('messages.subscription.torpedo')
2015-04-20 18:12:11 -07:00
state = Subscription.unsubscribe(current_user, Answer.find(params[:answer])).nil?
@response[:success] = state == false
2015-04-20 18:12:11 -07:00
end
end