Sha256: 5dca1c771613a4bd824f410b26b84fee80c5a601acc5b1cc5c759c9666d3cee7

Contents?: true

Size: 897 Bytes

Versions: 2

Compression:

Stored size: 897 Bytes

Contents

module Commontator
  class SubscriptionsController < Commontator::ApplicationController
    before_filter :get_thread

    # PATCH /threads/1/subscribe
    def subscribe
      raise SecurityTransgression unless @thread.can_subscribe?(@user)

      @thread.errors.add(:subscription, "You are already subscribed to this thread") \
        unless @thread.subscribe(@user)

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

    end

    # PATCH /threads/1/unsubscribe
    def unsubscribe
      raise SecurityTransgression unless @thread.can_subscribe?(@user)

      @thread.errors.add(:subscription, "You are not subscribed to this thread") \
        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-4.0.1 app/controllers/commontator/subscriptions_controller.rb
commontator-4.0.0 app/controllers/commontator/subscriptions_controller.rb