diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2025-11-21 21:01:50 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2025-11-21 21:01:50 -0500 |
| commit | 4a9bf38ef61b39e482458ba56cd1e6fea379b4d7 (patch) | |
| tree | ed778402e454cbbb3945f453f6d1682f4701924a /app/controllers | |
| parent | c260fbba4ed7cd0e7b80d5ae1316f597f9abb827 (diff) | |
| download | thoughts-4a9bf38ef61b39e482458ba56cd1e6fea379b4d7.tar.gz thoughts-4a9bf38ef61b39e482458ba56cd1e6fea379b4d7.tar.bz2 thoughts-4a9bf38ef61b39e482458ba56cd1e6fea379b4d7.zip | |
Added "listening to" box in sidebar
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/application_controller.rb | 10 |
1 files changed, 10 insertions, 0 deletions
| 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 @@ | |||
| 1 | class ApplicationController < ActionController::Base | 1 | class ApplicationController < ActionController::Base |
| 2 | protect_from_forgery with: :exception | 2 | protect_from_forgery with: :exception |
| 3 | before_action :choose_random_song | ||
| 3 | 4 | ||
| 4 | private | 5 | private |
| 5 | 6 | ||
| 6 | def after_sign_out_path_for(resource) | 7 | def after_sign_out_path_for(resource) |
| 7 | new_session_path(resource) | 8 | new_session_path(resource) |
| 8 | end | 9 | end |
| 10 | |||
| 11 | def choose_random_song | ||
| 12 | ids = Scrobble.ids | ||
| 13 | if ids.empty? | ||
| 14 | @random_song = nil | ||
| 15 | else | ||
| 16 | @random_song = Scrobble.find(ids.sample) | ||
| 17 | end | ||
| 18 | end | ||
| 9 | end | 19 | end |
