Class: Commontator::SubscriptionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Commontator::SubscriptionsController
- Defined in:
- app/controllers/commontator/subscriptions_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /1/subscribe.
-
#destroy ⇒ Object
POST /1/unsubscribe.
Instance Method Details
#create ⇒ Object
POST /1/subscribe
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?(@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 |
#destroy ⇒ Object
POST /1/unsubscribe
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?(@user) @thread.errors.add(:subscription, "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 |