Sha256: 0a1bb00436bec4b7f568ad2f6d76b495484c67d77b612a1b348a505f9b045ca8
Contents?: true
Size: 848 Bytes
Versions: 3
Compression:
Stored size: 848 Bytes
Contents
class HelpCenter::ApplicationController < ::ApplicationController layout "help_center" def page_number page = params.fetch(:page, '').gsub(/[^0-9]/, '').to_i page = "1" if page.zero? page end def is_moderator_or_owner?(object) is_moderator? || object.user == current_user end helper_method :is_moderator_or_owner? def is_moderator? current_user.respond_to?(:moderator) && current_user.moderator? end helper_method :is_moderator? def require_mod_or_author_for_post! unless is_moderator_or_owner?(@support_post) redirect_to_root end end def require_mod_or_author_for_thread! unless is_moderator_or_owner?(@support_thread) redirect_to_root end end private def redirect_to_root redirect_to help_center.root_path, alert: "You aren't allowed to do that." end end
Version data entries
3 entries across 3 versions & 1 rubygems