Sha256: 3d8b6ec7e2d2f52776efd365cea0165e3337f550658eb260d5c5af7dda763b2d

Contents?: true

Size: 892 Bytes

Versions: 6

Compression:

Stored size: 892 Bytes

Contents

module Commontator
  class SubscriptionsController < Commontator::ApplicationController
    before_filter :get_thread

    # PUT /threads/1/subscribe
    def subscribe
      security_transgression_unless @thread.can_subscribe?(@user)

      @thread.errors.add(:base, t('commontator.subscription.errors.already_subscribed')) \
        unless @thread.subscribe(@user)

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

    end

    # PUT /threads/1/unsubscribe
    def unsubscribe
      security_transgression_unless @thread.can_subscribe?(@user)

      @thread.errors.add(:base, t('commontator.subscription.errors.not_subscribed')) \
        unless @thread.unsubscribe(@user)

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
commontator-4.8.0 app/controllers/commontator/subscriptions_controller.rb
commontator-4.7.2 app/controllers/commontator/subscriptions_controller.rb
commontator-4.7.1 app/controllers/commontator/subscriptions_controller.rb
commontator-4.7.0 app/controllers/commontator/subscriptions_controller.rb
commontator-4.6.1 app/controllers/commontator/subscriptions_controller.rb
commontator-4.6.0 app/controllers/commontator/subscriptions_controller.rb