Vanity, Rails 3 and Heroku

二次信任 提交于 2019-12-05 05:37:34

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!