Skip to content

Instantly share code, notes, and snippets.

@mikepack
Created February 12, 2012 20: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 mikepack/1810540 to your computer and use it in GitHub Desktop.
Save mikepack/1810540 to your computer and use it in GitHub Desktop.
post '/interests' do
# Connect to Redis
uri = URI.parse(ENV["REDIS_URL"] || 'redis://localhost:6379')
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
# Parse the JSON body
join = JSON.parse(request.body.read)
# Register the user's interest in an artist
REDIS.sadd("artists:#{join['artist_id']}", join['user_id'])
REDIS.sadd("users:#{join['user_id']}", join['artist_id'])
status 201
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment