Sha256: 94d13382b0e04c837dc97c334ef11f25b14fc8c45d714e4ad3cff5d45408f704

Contents?: true

Size: 890 Bytes

Versions: 7

Compression:

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

7 entries across 7 versions & 1 rubygems

Version Path
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~