Sha256: e300121765bce029d245fe743039bce4f17834feb3a5312ad4cbc510d68c2d6b

Contents?: true

Size: 895 Bytes

Versions: 3

Compression:

Stored size: 895 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

3 entries across 3 versions & 1 rubygems

Version Path
commontator-2.0.2 app/controllers/commontator/subscriptions_controller.rb~
commontator-4.0.1 app/controllers/commontator/subscriptions_controller.rb~
commontator-4.0.0 app/controllers/commontator/subscriptions_controller.rb~