Rails 3.1资产:预编译连接到数据库 [英] Rails 3.1 assets:precompile Connecting to Database

查看:107
本文介绍了Rails 3.1资产:预编译连接到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在使用资产管道升级到Rails 3.1之后将应用程序部署到Heroku。在遇到错误时,我遇到了Heroku的疑难解答页中提到的常见问题:

 无法连接到服务器:连接被拒绝
服务器在主机127.0.0.1上运行并接受
端口xxxx上的TCP / IP连接?

我在页面上提出了建议,并将以下内容添加到我的config / application.rb文件中也试图将它添加到个人的[环境] .rb文件中无效)

  config.assets.initialize_on_precompile = false 

我修改了我的database.yml文件,将我的生产环境指向了不存在的数据库,但当运行资产:本地预编译任务时,我得到以下内容:

 > RAILS_ENV =生产包exec rake资产:预编译 - 跟踪
**调用资源:预编译(first_time)
**执行资源:预编译
rake中止!
FATAL:数据库my_nonexistant_database不存在

任务:TOP =>环境
(通过使用--trace运行任务查看完整跟踪)

我正在尝试弄清楚我的应用程序的哪个部分正在尝试初始化数据库,以便我可以修复它,但是我已经用尽了获取更多调试信息的想法。



任何人都可以获得关于我的应用在哪里试图启动数据库或者解决潜在问题的更多信息? >解决方案

您应该尝试新的实验室功能 http ://devcenter.heroku.com/articles/labs-user-env-compile ,它将使变量在slug编译时可用。


I'm trying to deploy an application to Heroku after upgrading to Rails 3.1 with the asset pipeline. I ran into the common issue mentioned on Heroku's troubleshooting page when receiving the error:

could not connect to server: Connection refused 
Is the server running on host "127.0.0.1" and accepting 
TCP/IP connections on port xxxx?

I took the suggestions on the page and added the following to my config/application.rb file (after also trying to add it to the individual [environment].rb files to no effect)

config.assets.initialize_on_precompile = false

I've modified my database.yml file to point my production environment to a non-existant database, but when running the assets:precompile task locally, I get the following:

> RAILS_ENV=production bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
rake aborted!
FATAL:  database "my_nonexistant_database" does not exist

Tasks: TOP => environment
(See full trace by running task with --trace)

I'm trying to figure out what part of my application is trying to initialize the database so that I can fix it, but I've run out of ideas for getting more debugging information than this.

Anyone have any tips for either getting more information about where my app is trying to init the DB, or for fixing the underlying problem?

解决方案

You should try the new labs feature http://devcenter.heroku.com/articles/labs-user-env-compile which will make variables available at slug compile time.

这篇关于Rails 3.1资产:预编译连接到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆