Sha256: 26e5452a5e05374904720a2461520935f614b4424efd15b5b824c24ea6287b47

Contents?: true

Size: 900 Bytes

Versions: 3

Compression:

Stored size: 900 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 @commontable_url }
        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 @commontable_url }
        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~