Sha256: a99b5776085a5ed18ed85f641ce88f9595564a4970197fc96288f805f724ddff

Contents?: true

Size: 891 Bytes

Versions: 9

Compression:

Stored size: 891 Bytes

Contents

module Commontator
  class SubscriptionsController < Commontator::ApplicationController
    before_filter :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

9 entries across 9 versions & 1 rubygems

Version Path
commontator-4.11.1 app/controllers/commontator/subscriptions_controller.rb
commontator-4.11.0 app/controllers/commontator/subscriptions_controller.rb
commontator-4.10.5 app/controllers/commontator/subscriptions_controller.rb
commontator-4.10.4 app/controllers/commontator/subscriptions_controller.rb
commontator-4.10.3 app/controllers/commontator/subscriptions_controller.rb
commontator-4.10.2 app/controllers/commontator/subscriptions_controller.rb
commontator-4.10.1 app/controllers/commontator/subscriptions_controller.rb
commontator-4.10.0 app/controllers/commontator/subscriptions_controller.rb
commontator-4.9.0 app/controllers/commontator/subscriptions_controller.rb