Class: SongsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/songs_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
5
6
7
8
9
10
11
# File 'app/controllers/songs_controller.rb', line 3

def index

  @songs = Song.published.all

  respond_to do |format|
    format.json { render json: @songs }
  end

end

#playerObject



23
24
25
26
27
# File 'app/controllers/songs_controller.rb', line 23

def player
  @shuffled = params[:shuffled] || false
  @songs_api = @shuffled ? shuffled_songs_path(:json) : songs_path(:json)
  render layout: false
end

#shuffledObject



13
14
15
16
17
18
19
20
21
# File 'app/controllers/songs_controller.rb', line 13

def shuffled

  @songs = Song.published.all.shuffle

  respond_to do |format|
    format.json { render json: @songs }
  end
  
end