Sha256: b6ab77867392c5684aacb369adb1807fc604d056c9452577c94c5ad4158a9409

Contents?: true

Size: 898 Bytes

Versions: 9

Compression:

Stored size: 898 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(: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

    # POST /1/unsubscribe
    def destroy
      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

9 entries across 9 versions & 1 rubygems

Version Path
commontator-1.1.1 app/controllers/commontator/subscriptions_controller.rb~
commontator-1.1.0 app/controllers/commontator/subscriptions_controller.rb~
commontator-1.0.6 app/controllers/commontator/subscriptions_controller.rb
commontator-1.0.5 app/controllers/commontator/subscriptions_controller.rb
commontator-1.0.4 app/controllers/commontator/subscriptions_controller.rb
commontator-1.0.3 app/controllers/commontator/subscriptions_controller.rb
commontator-1.0.2 app/controllers/commontator/subscriptions_controller.rb
commontator-1.0.1 app/controllers/commontator/subscriptions_controller.rb
commontator-1.0.0 app/controllers/commontator/subscriptions_controller.rb