Rails3.1 heroku 部署遇到很多麻烦

发布于 2024-12-10 14:34:24 字数 1876 浏览 0 评论 0原文

我在部署一个简单的 Rails3.1 应用程序时遇到很多麻烦。似乎有两个主要问题。

  1. 由于资产管道的原因,资产不会加载到生产环境中。
  2. 我使用默认的db sqlite3进行开发。 Heroku 使用 postgresql。

基本上,我希望我的开发到部署工作流程尽可能无缝。任何人都可以推荐设置我的开发环境的最佳方法,以便当我 $git push heroku 时,一切正常。

我想最好在开发环境中使用 postgresql,有人知道关于如何设置它的好帖子吗?

我应该使用独角兽吗?薄的?

我应该使用我可能没有听说过的其他宝石吗?

我感到沮丧,因为我已经到了可以在开发环境中构建非常酷的东西的地步,但不知道如何让应用程序上线。也许我对这一切的看法都是错误的。让我知道。

当我尝试执行以下操作时出现此错误:

group :production do
    gem 'pg' 
end

Installing pg (0.11.0) with native extensions /home/work/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /home/work/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/work/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config

I am having a lot of trouble deploying a simple rails3.1 app. It seems like there are two main problems.

  1. Because of the asset pipeline, the assets are not loading in the production environment.
  2. I develop with the default db sqlite3. Heroku uses postgresql.

Basically, I want my development-to-deploy workflow to be as seamless as possible. Can anyone recommend the best way to set up my development environment, so that when I $git push heroku, everything just works.

I imagine that it is best to use postgresql in the development environment, Anyone know of a good post on how to set this up?

Should I use unicorn? thin?

Should I be using any other gems that I may not have heard of?

I feel frustrated because I have gotten to the point where I can build pretty cool stuff in the development environment, but have no clue how to get the app online. Maybe I am looking at this all wrong. let me know.

I get this error when I try to do:

group :production do
    gem 'pg' 
end

Installing pg (0.11.0) with native extensions /home/work/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /home/work/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/work/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

猫腻 2024-12-17 14:34:24

在提交之前,运行以下命令来预编译您的资产:

gt; bundle exec rake assets:precompile

之外,您不需要为 heroku 数据库设置任何内容

gem 'pg' 

除了放入 gemfile 的生产部分 。剩下的一切都是它自己解决的。

我经常使用的一些不错的技巧是:

gt; heroku db:push
gt; heroku db:pull

阅读有关推送和推送的内容。 pull 这里

我在 mysql 上进行本地开发,因为它有最好的前端恕我直言,但是您也可以使用 sqlite3 或 postgres,具体取决于您希望在原始表中工作的程度。

Before your commit run the following to precompile your assets:

gt; bundle exec rake assets:precompile

You shouldn't need to set up anything for the heroku database other than putting

gem 'pg' 

in the production section of your gemfile. It figures it all out all the rest on its own.

Some nice tricks I use quite a bit are:

gt; heroku db:push
gt; heroku db:pull

Read about push & pull here

I develop locally on mysql since it has the best front end IMHO, but you would be fine using sqlite3 or postgres too, depending on how much you want to be working in raw tables.

Oo萌小芽oO 2024-12-17 14:34:24

我遇到了这个问题,但我改用了雪松堆栈,这似乎解决了资产问题。至于DB,只需

group :production do
    gem 'pg' 
end

在gemfile中指定即可

I had that problem, but I changed to the cedar stack and that seemed to solve the asset problem. As for the DB, just specify

group :production do
    gem 'pg' 
end

in the gemfile

凌乱心跳 2024-12-17 14:34:24

实际上,我使用了您两个答案中的信息来使其发挥作用。我的资产问题是通过 bundle exec rake assets:precompile 解决的,我的数据库问题是通过

group :production do
    gem 'pg' 
end

添加以下内容解决的:

group :development do
    gem 'sqlite3' 
end

Actually I used the information from both of your answers to get it to work. My asset problem was solved with the bundle exec rake assets:precompile and my db problem was solved by

group :production do
    gem 'pg' 
end

and also adding this:

group :development do
    gem 'sqlite3' 
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文