我使用免费的heroku实例来运行我的Dashing项目。因此,当我的实例休眠时,它会松开先前传递的值。我被推荐使用Redis来保存历史。我试着遵循给这里的指令。结果,我得到了以下config.ru (作为我的dashing项目的一部分):
require 'dashing'
require 'redis-objects'
require 'yaml'
configure do
set :auth_token, 'my-token'
set :default_dashboard, 'def' # https://github.com/Shopify/dashing/wiki/How-To:-Change-the-default-dashboard
helpers do
def protected!
# Put any authentication code you want in here.
# This method is run before accessing any resource.
end
end
end
def redis?
ENV.has_key? 'REDISTOGO_URL'
end
if redis?
redis_uri = URI.parse(ENV['REDISTOGO_URL'])
Redis.current = Redis.new(:host => redis_uri.host,
:port => redis_uri.port,
:password => redis_uri.password)
set :history, Redis::HashKey.new('dashing-history')
elsif File.exists?(settings.history_file)
set history: YAML.load_file(settings.history_file)
else
set history: {}
end
map Sinatra::Application.assets_prefix do
run Sinatra::Application.sprockets
end
run Sinatra::Application和下面的Gemfile
source 'https://rubygems.org'
gem 'dashing'
gem 'redis-objects'
## Remove this if you don't need a twitter widget.
gem 'twitter', '>= 5.9.0'但没什么用。我做错了什么?我还尝试使用这教程。但是它给了我一个redis_uri = URI.parse(ENV["REDISTOGO_URL"])行的错误(类似于wrong url is given)。
https://stackoverflow.com/questions/35708708
复制相似问题