Sha256: 5acf0158fdd402e64909511b21f30d6016890ec50160f762a3d985305eb9abb4
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
module Thredded class ApplicationController < ::ApplicationController helper Thredded::Engine.helpers helper_method :messageboard, :preferences layout Thredded.layout rescue_from CanCan::AccessDenied, Thredded::Errors::MessageboardNotFound, Thredded::Errors::MessageboardReadDenied, Thredded::Errors::TopicCreateDenied do |exception| redirect_to thredded.root_path, alert: exception.message end rescue_from Thredded::Errors::EmptySearchResults, Thredded::Errors::TopicNotFound do |exception| redirect_to messageboard_topics_path(messageboard), alert: exception.message end private def authorize_reading(obj) if cannot? :read, obj class_name = obj.class.to_s error = class_name .gsub(/Thredded::/, 'Thredded::Errors::') + 'ReadDenied' raise error.constantize end end def authorize_creating(obj) if cannot? :create, obj class_name = obj.class.to_s error = class_name .gsub(/Thredded::/, 'Thredded::Errors::') + 'CreateDenied' raise error.constantize end end def update_user_activity messageboard.update_activity_for!(current_user) end def current_ability @current_ability ||= Ability.new(current_user) end def messageboard @messageboard ||= Messageboard.find_by_slug(params[:messageboard_id]) end def preferences if current_user @preferences ||= UserPreference.where(user_id: current_user.id).first end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
thredded-0.0.12 | app/controllers/thredded/application_controller.rb |