about summary refs log tree commit diff stats
path: root/app/controllers/application_controller.rb
blob: ad46fb964fc432f21d1b73bd92981373d2a66a56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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