Class: DashboardController

Inherits:
ApplicationController show all
Defined in:
app/controllers/dashboard_controller.rb

Overview

Handles tracking user specific gaming history and statistics

Instance Method Summary collapse

Instance Method Details

#game_historyObject

This method sets the game history displayed to the user.

[View source]

22
23
24
25
# File 'app/controllers/dashboard_controller.rb', line 22

def game_history
  @game = Game.find(params[:game_id])
  @game_history = Dashboard.where(user_id: session[:user_id], game_id: @game.id).order(played_on: :desc)
end

#showObject

This method sets the dashboard details displayed to the user.

Sets the following attributes aggregated for all games: total_games_played, last_played_on, streak.

Sets the following attributes for each game: name, last_played_on, score

[View source]

12
13
14
15
16
17
18
19
# File 'app/controllers/dashboard_controller.rb', line 12

def show
  @dashboard_details = {}

  populate_total_games_played
  populate_last_played_on
  populate_streak
  populate_game_stats
end