Sha256: db7fc55b82c6e31eff03a87aff845ab62c5496354926aa21da1f5a5e0ee238bb

Contents?: true

Size: 882 Bytes

Versions: 3

Compression:

Stored size: 882 Bytes

Contents

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

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

      @thread.errors.add(:base, "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

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

      @thread.errors.add(:base, "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-0.5.14 app/controllers/commontator/subscriptions_controller.rb
commontator-0.5.13 app/controllers/commontator/subscriptions_controller.rb
commontator-0.5.12 app/controllers/commontator/subscriptions_controller.rb