Class: Formol::SubscriptionsController

Inherits:
ApplicationController show all
Includes:
Controllers::Nested::HasParentTopic
Defined in:
app/controllers/formol/subscriptions_controller.rb

Instance Method Summary collapse

Methods included from Controllers::Nested::HasParentTopic

#topic

Methods inherited from ApplicationController

#last_page_forum_topic_path, #paginated_forum_topic_post_path, #per_page, #topic_last_page_number, #topic_post_page_number

Instance Method Details

#createObject



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

def create
  formol_authorize!(current_formol_user, :subscribe_topic)
  
  topic.register_subscriber(current_formol_user)
  
  respond_to do |format|
    format.js { render :nothing => true, :status => :ok }
  end
rescue ActiveRecord::RecordInvalid
  respond_to do |format|
    format.js { render :nothing => true, :status => :unprocessable_entity }
  end
end

#destroyObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/formol/subscriptions_controller.rb', line 19

def destroy
  formol_authorize!(current_formol_user, :subscribe_topic)
  
  topic.unregister_subscriber(current_formol_user)
  
  respond_to do |format|
    format.js { render :nothing => true, :status => :ok }
  end
end