public
Created

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.