Class: Commontator::SubscriptionsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /1/subscribe

Raises:

  • (SecurityTransgression)


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

def create
  raise SecurityTransgression unless @thread.can_subscribe?(@commontator)

  @thread.errors.add(:base, "You are already subscribed to this thread") \
    unless @thread.subscribe(@commontator)

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

end

#destroyObject

POST /1/unsubscribe

Raises:

  • (SecurityTransgression)


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

def destroy
  raise SecurityTransgression unless @thread.can_subscribe?(@commontator)

  @thread.errors.add(:base, "You are not subscribed to this thread") \
    unless @thread.unsubscribe(@commontator)

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