# Class ApplicationController < ActionController::Base

- app/controllers/application_controller.rb

Methods

A
  - abilities,
  - access_denied!,
  - add_abilities,
  - after_sign_in_path_for,
  - authorize_code_access!,
  - authorize_project!
C
  - can?
D
  - dev_tools
G
  - git_not_found!
L
  - log_exception
M
  - method_missing
N
  - no_cache_headers,
  - not_found!
P
  - project
R
  - reject_blocked!,
  - render_403,
  - render_404,
  - require_non_empty_project
S
  - set_current_user_for_observers

Instance Protected methods
abilities() Link

Source: show

    # File app/controllers/application_controller.rb, line 58
    def abilities
      @abilities ||= Six.new
    end

access_denied!() Link

Source: show

    # File app/controllers/application_controller.rb, line 91
    def access_denied!
      render "errors/access_denied", layout: "errors", status: 404
    end

add_abilities() Link

Source: show

    # File app/controllers/application_controller.rb, line 79
    def add_abilities
      abilities << Ability
    end

after_sign_in_path_for(resource) Link

Source: show

    # File app/controllers/application_controller.rb, line 43
    def after_sign_in_path_for resource
      if resource.is_a?(User) && resource.respond_to?(:blocked) && resource.blocked
        sign_out resource
        flash[:alert] = "Your account is blocked. Retry when an admin unblock it."
        new_user_session_path
      else
        super
      end
    end

authorize_code_access!() Link

Source: show

    # File app/controllers/application_controller.rb, line 87
    def authorize_code_access!
      return access_denied! unless can?(current_user, :download_code, project)
    end

authorize_project!(action) Link

Source: show

    # File app/controllers/application_controller.rb, line 83
    def authorize_project!(action)
      return access_denied! unless can?(current_user, action, project)
    end

can?(object, action, subject) Link

Source: show

    # File app/controllers/application_controller.rb, line 62
    def can?(object, action, subject)
      abilities.allowed?(object, action, subject)
    end

dev_tools() Link

Source: show

    # File app/controllers/application_controller.rb, line 129
    def dev_tools
      Rack::MiniProfiler.authorize_request
    end

git_not_found!() Link

Source: show

    # File app/controllers/application_controller.rb, line 99
    def git_not_found!
      render "errors/git_not_found", layout: "errors", status: 404
    end

log_exception(exception) Link

Source: show

    # File app/controllers/application_controller.rb, line 29
    def log_exception(exception)
      application_trace = ActionDispatch::ExceptionWrapper.new(env, exception).application_trace
      application_trace.map!{ |t| "  #{t}\n" }
      logger.error "\n#{exception.class.name} (#{exception.message}):\n#{application_trace.join}"
    end

method_missing(method_sym, *arguments, &block) Link

Source: show

    # File app/controllers/application_controller.rb, line 103
    def method_missing(method_sym, *arguments, &block)
      if method_sym.to_s =~ %r^authorize_(.*)!$/
        authorize_project!($1.to_sym)
      else
        super
      end
    end

no_cache_headers() Link

Source: show

    # File app/controllers/application_controller.rb, line 123
    def no_cache_headers
      response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
      response.headers["Pragma"] = "no-cache"
      response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
    end

not_found!() Link

Source: show

    # File app/controllers/application_controller.rb, line 95
    def not_found!
      render "errors/not_found", layout: "errors", status: 404
    end

project() Link

Source: show

    # File app/controllers/application_controller.rb, line 66
    def project
      id = params[:project_id] || params[:id]

      @project = Project.find_with_namespace(id)

      if @project and can?(current_user, :read_project, @project)
        @project
      else
        @project = nil
        render_404
      end
    end

reject_blocked!() Link

Source: show

    # File app/controllers/application_controller.rb, line 35
    def reject_blocked!
      if current_user && current_user.blocked
        sign_out current_user
        flash[:alert] = "Your account is blocked. Retry when an admin unblock it."
        redirect_to new_user_session_path
      end
    end

render_403() Link

Source: show

    # File app/controllers/application_controller.rb, line 115
    def render_403
      render file: Rails.root.join("public", "403"), layout: false, status: "403"
    end

render_404() Link

Source: show

    # File app/controllers/application_controller.rb, line 111
    def render_404
      render file: Rails.root.join("public", "404"), layout: false, status: "404"
    end

require_non_empty_project() Link

Source: show

    # File app/controllers/application_controller.rb, line 119
    def require_non_empty_project
      redirect_to @project if @project.empty_repo?
    end

set_current_user_for_observers() Link

Source: show

    # File app/controllers/application_controller.rb, line 53
    def set_current_user_for_observers
      MergeRequestObserver.current_user = current_user
      IssueObserver.current_user = current_user
    end