root_controller.rb 997 字节
Newer Older
R
Robert Speicher 已提交
1 2 3 4 5 6 7 8
# RootController
#
# This controller exists solely to handle requests to `root_url`. When a user is
# logged in and has customized their `dashboard` setting, they will be
# redirected to their preferred location.
#
# For users who haven't customized the setting, we simply delegate to
# `DashboardController#show`, which is the default.
9
class RootController < Dashboard::ProjectsController
D
Douwe Maan 已提交
10
  before_action :redirect_to_custom_dashboard, only: [:index]
R
Robert Speicher 已提交
11

12
  def index
R
Robert Speicher 已提交
13 14 15 16 17 18 19 20 21
    super
  end

  private

  def redirect_to_custom_dashboard
    return unless current_user

    case current_user.dashboard
R
Robert Speicher 已提交
22
    when 'stars'
23
      flash.keep
R
Robert Speicher 已提交
24
      redirect_to starred_dashboard_projects_path
25 26 27 28
    when 'project_activity'
      redirect_to activity_dashboard_path
    when 'starred_project_activity'
      redirect_to activity_dashboard_path(filter: 'starred')
29 30 31 32
    when 'groups'
      redirect_to dashboard_groups_path
    when 'todos'
      redirect_to dashboard_todos_path
R
Robert Speicher 已提交
33
    else
R
Robert Speicher 已提交
34
      return
R
Robert Speicher 已提交
35 36 37
    end
  end
end