Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Prepare the redis connection for redis to go on Heroku

  • Loading branch information...
commit 3a935ef984fb1b3f650fb919a7ae67755b90bed5 1 parent 75c2899
Christopher Cooke authored March 10, 2012

Showing 1 changed file with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. 8  pastr_app.rb
8  pastr_app.rb
@@ -7,7 +7,9 @@
7 7
 class PastrApp < Sinatra::Base
8 8
   register Mustache::Sinatra
9 9
 
10  
-  @@redis = Redis.new(:host => 'localhost', :port => 6379)
  10
+  ENV["REDISTOGO_URL"] = 'redis://localhost:6379' if ENV["RACK_ENV"] != 'production'
  11
+  uri = URI.parse(ENV["REDISTOGO_URL"])
  12
+  REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
11 13
 
12 14
   require 'views/layout'
13 15
 
@@ -22,12 +24,12 @@ class PastrApp < Sinatra::Base
22 24
 
23 25
   post '/' do
24 26
     id = Digest::MD5.hexdigest(params[:code])
25  
-    @@redis.set "pastr:#{id}", params[:code]
  27
+    REDIS.set "pastr:#{id}", params[:code]
26 28
     redirect "/#{id}"
27 29
   end
28 30
 
29 31
   get '/:id' do |id|
30  
-    @code = @@redis.get "pastr:#{id}"
  32
+    @code = REDIS.get "pastr:#{id}"
31 33
     mustache :show
32 34
   end
33 35
 end

0 notes on commit 3a935ef

Please sign in to comment.
Something went wrong with that request. Please try again.