Created
November 22, 2012 12:02
-
-
Save hoguej/4130794 to your computer and use it in GitHub Desktop.
web.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post '/play_list/?' do | |
puts params.inspect | |
id = very_clean( params[:_id] ) | |
# validations | |
raise "Id cannot be blank" if id.nil? | |
raise "Id cannot be blank" if id.empty? | |
raise "Id must be a String" unless id.is_a? String | |
raise "That play list already exists" if find_play_list( id ) | |
# make sure to use a clean id | |
play_list = params | |
play_list["_id"] = id | |
# return | |
content_type :json | |
settings.play_lists.insert play_list | |
return find_play_list( id ).to_json | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment