class ApplicationController

Protected Instance Methods

abilities() click to toggle source
# File app/controllers/application_controller.rb, line 48
def abilities
  @abilities ||= Six.new
end
access_denied!() click to toggle source
# File app/controllers/application_controller.rb, line 73
def access_denied!
  render "errors/access_denied", layout: "errors", status: 404
end
add_project_abilities() click to toggle source
# File app/controllers/application_controller.rb, line 61
def add_project_abilities
  abilities << Ability
end
after_sign_in_path_for(resource) click to toggle source
# File app/controllers/application_controller.rb, line 33
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 was blocked"
    new_user_session_path
  else
    super
  end
end
authorize_code_access!() click to toggle source
# File app/controllers/application_controller.rb, line 69
def authorize_code_access!
  return access_denied! unless can?(current_user, :download_code, project)
end
authorize_project!(action) click to toggle source
# File app/controllers/application_controller.rb, line 65
def authorize_project!(action)
  return access_denied! unless can?(current_user, action, project)
end
can?(object, action, subject) click to toggle source
# File app/controllers/application_controller.rb, line 52
def can?(object, action, subject)
  abilities.allowed?(object, action, subject)
end
dev_tools() click to toggle source
# File app/controllers/application_controller.rb, line 107
def dev_tools
  Rack::MiniProfiler.authorize_request
end
git_not_found!() click to toggle source
# File app/controllers/application_controller.rb, line 81
def git_not_found!
  render "errors/git_not_found", layout: "errors", status: 404
end
method_missing(method_sym, *arguments, &block) click to toggle source
# File app/controllers/application_controller.rb, line 85
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() click to toggle source
# File app/controllers/application_controller.rb, line 101
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!() click to toggle source
# File app/controllers/application_controller.rb, line 77
def not_found!
  render "errors/not_found", layout: "errors", status: 404
end
project() click to toggle source
# File app/controllers/application_controller.rb, line 56
def project
  @project ||= current_user.projects.find_by_code(params[:project_id] || params[:id])
  @project || render_404
end
reject_blocked!() click to toggle source
# File app/controllers/application_controller.rb, line 25
def reject_blocked!
  if current_user && current_user.blocked
    sign_out current_user
    flash[:alert] = "Your account was blocked"
    redirect_to new_user_session_path
  end
end
render_404() click to toggle source
# File app/controllers/application_controller.rb, line 93
def render_404
  render file: Rails.root.join("public", "404"), layout: false, status: "404"
end
require_non_empty_project() click to toggle source
# File app/controllers/application_controller.rb, line 97
def require_non_empty_project
  redirect_to @project if @project.empty_repo?
end
set_current_user_for_observers() click to toggle source
# File app/controllers/application_controller.rb, line 43
def set_current_user_for_observers
  MergeRequestObserver.current_user = current_user
  IssueObserver.current_user = current_user
end