LA_ LA_ - 1 year ago 112
Ruby Question

How to enable redis for Dashing?

I use free heroku instance to run my Dashing project. In result, it looses the value passed previously, when my instance sleeps. I was recommended to use Redis to keep history. I tryed to follow the instruction given here. In result I got the following
(as part of my dashing project):

require 'dashing'
require 'redis-objects'
require 'yaml'

configure do
set :auth_token, 'my-token'
set :default_dashboard, 'def' #

helpers do
def protected!
# Put any authentication code you want in here.
# This method is run before accessing any resource.

def redis?

if redis?
redis_uri = URI.parse(ENV['REDISTOGO_URL'])
Redis.current = =>,
:port => redis_uri.port,
:password => redis_uri.password)

set :history,'dashing-history')
elsif File.exists?(settings.history_file)
set history: YAML.load_file(settings.history_file)
set history: {}

map Sinatra::Application.assets_prefix do
run Sinatra::Application.sprockets

run Sinatra::Application

and the following

source ''

gem 'dashing'
gem 'redis-objects'

## Remove this if you don't need a twitter widget.
gem 'twitter', '>= 5.9.0'

But it didn't help. What I did incorrectly?
I also tried to use this tutorial. But it was giving me an error at line
redis_uri = URI.parse(ENV["REDISTOGO_URL"])
(something like
wrong url is given

Answer Source

The problem was that the app requires the add-on Redis To Go
If Redis To Go is configured, REDISTOGO_URL is added to environment variables, it will work

For more information on how to setup Redis To Go, read the heroku article

Adding Redis to an application provides benefits, you may be using RedisToGo to power simple Resque or Sidekiq jobs, or using the raw power of Redis 2.6 Lua Scripting to do some crazy fast operations. Redis can be used a database, but it’s often used as a complementary datastore. With over 140 commands, the possibilities are endless.