Sha256: 890c9c0ccf74d1e1acc93e50252f6449ad26e0110e108a20b2a4242d8fc2536a

Contents?: true

Size: 893 Bytes

Versions: 6

Compression:

Stored size: 893 Bytes

Contents

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

    # PUT /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

    # PUT /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

6 entries across 6 versions & 1 rubygems

Version Path
commontator-4.2.2 app/controllers/commontator/subscriptions_controller.rb
commontator-4.2.1 app/controllers/commontator/subscriptions_controller.rb
commontator-4.2.0 app/controllers/commontator/subscriptions_controller.rb
commontator-4.1.2 app/controllers/commontator/subscriptions_controller.rb
commontator-4.1.1 app/controllers/commontator/subscriptions_controller.rb
commontator-4.0.2 app/controllers/commontator/subscriptions_controller.rb