Skip to content

Instantly share code, notes, and snippets.

@hoguej
Created November 22, 2012 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoguej/4130794 to your computer and use it in GitHub Desktop.
Save hoguej/4130794 to your computer and use it in GitHub Desktop.
web.rb
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