I'm trying to get Vanity to play nicely with Heroku and my Rails 3 app. At the moment, it all works fine locally using Pow and a local Redis server, but when I push to Heroku using the RedisToGo add-on, nothing seems to get the server running, I just get the error: getaddrinfo: Name or service not known
.
Here's my config/vanity.yml file:
staging:
adapter: redis
host: <%= ENV["REDISTOGO_URL"] %>
and my config/initializers/redis.rb:
uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
I've also tried using the actual redis://<actualusername>:[email protected]:9274
and it gives the same error. I've also tried with and without the redis://
.
Has anyone got Vanity working with Heroku and Rails 3? Am I missing something terribly obvious? My Google-fu has failed me thus far.
Yeah, it was something stupid, all right. You don't use host
, you use connection
.
staging:
adapter: redis
connection: <%= ENV["REDISTOGO_URL"] %>
Hope this helps someone, because I nearly beat my computer to a pulp.
If you are using Postgres on Heroku you need to do things a bit different. Here is my hack (config/vanity.yml):
production:
adapter: active_record
active_record_adapter: postgresql
<% username, password, host, database = ENV['DATABASE_URL'].scan(%r{//(.*):(.*)@(.*)/(.*)}).first %>
host: <%= host %>
username: <%= username %>
password: <%= password %>
database: <%= database %>
And you have to force Vanity to not use the Redis adapter (a bug if you ask me). Put this in an initializer:
Vanity.playground.establish_connection(Rails.env.to_sym)
One final note: If you're using ActiveRecord & Postgres on Heroku and you ARE NOT on the shared database, the connection string should be:
username, password, host, port, database = ENV['DATABASE_URL'].scan(%r{//(.*):(.*)@(.*):(.*)/(.*)}).first
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With