Sha256: c0b21d30d9a2e7b7bb26a54ccad27574c24c339fa2f300e9f73a2a24e9a321ea

Contents?: true

Size: 891 Bytes

Versions: 2

Compression:

Stored size: 891 Bytes

Contents

module Commontator
  class SubscriptionsController < Commontator::ApplicationController
    before_action :set_thread

    # PUT /threads/1/subscribe
    def subscribe
      security_transgression_unless @thread.can_subscribe?(@user)

      @thread.errors.add(:base, t('commontator.subscription.errors.already_subscribed')) \
        unless @thread.subscribe(@user)

      respond_to do |format|
        format.html { redirect_to @thread }
        format.js { render :subscribe }
      end

    end

    # PUT /threads/1/unsubscribe
    def unsubscribe
      security_transgression_unless @thread.can_subscribe?(@user)

      @thread.errors.add(:base, t('commontator.subscription.errors.not_subscribed')) \
        unless @thread.unsubscribe(@user)

      respond_to do |format|
        format.html { redirect_to @thread }
        format.js { render :subscribe }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
commontator-5.1.0 app/controllers/commontator/subscriptions_controller.rb
commontator-5.0.0 app/controllers/commontator/subscriptions_controller.rb