Sha256: 8ba0502558736d59f88141bf370e011a8c0c7c2292f56268d496ac20068e3194

Contents?: true

Size: 829 Bytes

Versions: 2

Compression:

Stored size: 829 Bytes

Contents

module Commontator
  class ApplicationController < ActionController::Base
    before_filter :get_user
    
    cattr_accessor :commontable_url
    
    rescue_from SecurityTransgression, :with => lambda { head(:forbidden) }
    
    protected
    
    def get_user
      @user = self.send Commontator.current_user_method	
      raise SecurityTransgression unless (@user.nil? || @user.is_commontator)
    end
    
    def get_thread
      @thread = params[:thread_id].blank? ? \
        Commontator::Thread.find(params[:id]) : \
        Commontator::Thread.find(params[:thread_id])
      raise SecurityTransgression if @thread.commontable.nil?
      set_commontable_url
    end
    
    def set_commontable_url
      self.commontable_url = @thread.config.commontable_url_proc.call(main_app, @thread.commontable)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
commontator-1.1.1 app/controllers/commontator/application_controller.rb~
commontator-1.1.0 app/controllers/commontator/application_controller.rb~