2011-10-18 56 views
1

我在部署一個簡單的rails3.1應用程序時遇到了很多麻煩。似乎有兩個主要問題。用rails3.1 heroku部署很多麻煩

  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 

回答

1

您提交運行下面的預編譯的資產之前:

$> bundle exec rake assets:precompile 

你不應該需要設置何事heroku數據庫比放

gem 'pg' 

在您的gemfile的生產部分。它自己將所有其餘的數據全部歸納出來。

我用相當多的一些不錯的技巧是:

$> heroku db:push 
$> heroku db:pull 

閱讀有關推&拉here

我對MySQL的,因爲它有最好的前端恕我直言,在當地發展,但你會被罰款使用sqlite3或postgres也取決於你想在原始表格中工作多少。

+0

呵呵,我認爲它工作。剛剛嘗試了一個新的普通導軌應用程序和導軌標誌現在顯示。現在我要用我的實際應用程序來嘗試。謝謝 –

+0

nope不能用我的實際應用程序,但。只要繼續收到500錯誤頁面 –

+0

如果您的開發機器上的pg gem遇到問題,請閱讀[here](https://bitbucket.org/ged/ruby-pg/wiki/Home) – trogdor33

1

我有這個問題,但我改爲雪松堆棧,這似乎解決資產問題。至於數據庫,只需指定

group :production do 
    gem 'pg' 
end 

在Gemfile中

+0

我需要指定一個發展寶石集團爲好,或不捆綁承擔寶石'sqlite3'只用於開發? –

+0

我指定它使用gem'sqlite3','1.3.4',:group =>:開發 –

0

其實我使用了你的兩個答案的信息來使它工作。我的資產問題與bundle exec rake assets:precompile解決,我的數據庫問題是由

group :production do 
    gem 'pg' 
end 

解決,並且還加入了這一點:

group :development do 
    gem 'sqlite3' 
end 
+1

Heroku將預編譯您的資產作爲部署過程的一部分 - 我的Rails 3.1應用程序的部署過程是一個簡單的git push heroku命令。 http://devcenter.heroku.com/articles/rails31_heroku_cedar –