Guest User

Untitled

a guest
Feb 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. # In Rails Controller
  2. def playlist
  3. @playlist = session[:playlist] = Playlist.new(current_user)
  4. render :layout => false
  5. end
  6.  
  7. # In RAILS view
  8. xml.instruct! :xml, :version=>"1.0"
  9. xml.playlist do
  10. if @playlist.currently_playing?
  11. xml.currently_playing do
  12. xml.song_in_list @playlist.current_song_in_playlist?
  13. end
  14. end
  15.  
  16. xml.songs do
  17. @playlist.songs.each do |song|
  18. xml.song do
  19. xml.id song.id
  20. xml.title song.title
  21. xml.artist song.artist
  22. xml.path song.public_path
  23. end
  24. end
  25. end
  26. end
  27.  
  28. # Would generate
  29. <instruct...(whatever the XML stuff is for it>
  30. <playlist>
  31. <currently_playing>
  32. <song_in_list>12</song_in_list>
  33. </currently_playing>
  34.  
  35. <songs>
  36. <song>
  37. <id>32</id>
  38. <title>Some cool song</title>
  39. <artist>Foo Fighters</artist>
  40. <path>/path/to/cool_song.mp3</path>
  41. </song>
  42. </songs>
  43. </playlist>
Add Comment
Please, Sign In to add comment