Sha256: 33f50098216fedbe707e3a6c3ec5205801bc9b850b425bee3794c1b1b6e94613

Contents?: true

Size: 835 Bytes

Versions: 5

Compression:

Stored size: 835 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?
  end
  helper_method :is_moderator_or_owner?

  def is_moderator?
    current_user.respond_to?(:moderator) && current_user.moderator? || current_user.respond_to?(:admin) && current_user.admin?
  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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
help_center-0.1.0 app/controllers/help_center/application_controller.rb
help_center-0.0.9 app/controllers/help_center/application_controller.rb
help_center-0.0.8 app/controllers/help_center/application_controller.rb
help_center-0.0.7 app/controllers/help_center/application_controller.rb
help_center-0.0.6 app/controllers/help_center/application_controller.rb