Sha256: 82193afd1ae57c92faa15bb045769f87528cb224a94e2caa5634a567379a2cad

Contents?: true

Size: 815 Bytes

Versions: 3

Compression:

Stored size: 815 Bytes

Contents

module Formol
  class SubscriptionsController < ApplicationController
    include Formol::Controllers::Nested::HasParentTopic
    
    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
    
    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
formol-0.0.6 app/controllers/formol/subscriptions_controller.rb
formol-0.0.5 app/controllers/formol/subscriptions_controller.rb
formol-0.0.4 app/controllers/formol/subscriptions_controller.rb