Class: Commontator::SubscriptionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/commontator/subscriptions_controller.rb

Instance Method Summary collapse

Instance Method Details

#subscribeObject

PUT /threads/1/subscribe



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/commontator/subscriptions_controller.rb', line 6

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

#unsubscribeObject

PUT /threads/1/unsubscribe



20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/commontator/subscriptions_controller.rb', line 20

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