Sha256: 631a1cd3ad9c7c23c1c238053696fe122f4b987052ed798829d3e0049fecaf5f

Contents?: true

Size: 938 Bytes

Versions: 2

Compression:

Stored size: 938 Bytes

Contents

module Commontator
  class SubscriptionsController < ApplicationController
    helper ThreadsHelper
    
    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~