From 4a9bf38ef61b39e482458ba56cd1e6fea379b4d7 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 21 Nov 2025 21:01:50 -0500 Subject: Added "listening to" box in sidebar --- app/controllers/application_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0174cae..ad46fb9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,9 +1,19 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception + before_action :choose_random_song private def after_sign_out_path_for(resource) new_session_path(resource) end + + def choose_random_song + ids = Scrobble.ids + if ids.empty? + @random_song = nil + else + @random_song = Scrobble.find(ids.sample) + end + end end -- cgit 1.4.1