RoR应用程序部署

时间:2012-03-13 19:30:02

标签: ruby-on-rails

我将应用程序部署到heroku后运行“heroku run rake db:migrate”,我得到了这个:

$>> heroku run rake db:migrate

Running rake db:migrate attached to terminal... up, run.1
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/01/04/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/01/04/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/01/04/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)

Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)

我尝试安装提到的宝石但没有任何反应。我使用rails3一个ruby 1.9.3,我的database.yml文件包含:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

如何解决此错误?

编辑:

运行 $&gt;&gt; sudo gem install pg -v'0.13.2'

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.8 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=/usr/bin/ruby1.8
    --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


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/pg-0.13.2 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/pg-0.13.2/ext/gem_make.out

我收到此错误。我再次使用1.9.3版本的ruby。

2 个答案:

答案 0 :(得分:1)

您的database.yml设置为使用sqlite3。

如果你想使用postgresql,你需要先在你的电脑上安装postgres。

对于Linux:

sudo apt-get install postgresql

对于Max OS X:

brew install postgresql

让您先安装homebrew

heroku在deploy上自动生成database.yml。读取如下:你放在database.yml中的内容并不重要,这对我来说很好,因为我可以将它包含在git中,而不必担心生成db密码。

然后通过将它放在Gemfile中来安装pg gem:

gem'pg',:require =&gt; 'PG'

如果您使用的是旧版本的Rails,请使用gem install方法。

答案 1 :(得分:0)

尝试将'pg'gem添加到您的Gemfile(然后bundle install)。