Sha256: 8e78676e7e9a913dbf97700c64a6bcc9c3f0ef66ef93be14af98f51739162c28

Contents?: true

Size: 908 Bytes

Versions: 2

Compression:

Stored size: 908 Bytes

Contents

module Commontator
  class SubscriptionsController < ApplicationController
    before_filter :get_thread, :except => :index

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

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

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

    end

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

      @thread.errors.add(:base, "You are not subscribed to this thread") \
        unless @thread.unsubscribe(@commontator)

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
commontator-0.4.1 app/controllers/commontator/subscriptions_controller.rb
commontator-0.3.10 app/controllers/commontator/subscriptions_controller.rb