2013-02-12 118 views
1

我收到以下錯誤,同時實施耙分貝紅寶石實施的PostgreSQL:遷移錯誤而在軌道上

rake aborted! 
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) 

我已創建使用PostgreSQL數據庫中的兩個表。

我的database.yml是

development: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: shop_development 
    pool: 5 
    username: postgres 
    password: 

test: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: shop_test 
    pool: 5 
    username: postgres 
    password: 

production: 
    adapter: postgresql 
    encoding: unicode 
    host: localhost 
    database: shop_production 
    pool: 5 
    username: postgres 
    password: 

我也運行了命令,例如:

C:\Sites\shop>gem install 'pg' 
Successfully installed pg-0.14.1-x86-mingw32 
1 gem installed 
Installing ri documentation for pg-0.14.1-x86-mingw32... 
Installing RDoc documentation for pg-0.14.1-x86-mingw32... 

但這仍然給了我同樣的錯誤。

我的Gemfile有以下幾點:

GEM 
    remote: https://rubygems.org/ 
    specs: 
    actionmailer (3.2.11) 
     actionpack (= 3.2.11) 
     mail (~> 2.4.4) 
    actionpack (3.2.11) 
     activemodel (= 3.2.11) 
     activesupport (= 3.2.11) 
     builder (~> 3.0.0) 
     erubis (~> 2.7.0) 
     journey (~> 1.0.4) 
     rack (~> 1.4.0) 
     rack-cache (~> 1.2) 
     rack-test (~> 0.6.1) 
     sprockets (~> 2.2.1) 
    activemodel (3.2.11) 
     activesupport (= 3.2.11) 
     builder (~> 3.0.0) 
    activerecord (3.2.11) 
     activemodel (= 3.2.11) 
     activesupport (= 3.2.11) 
     arel (~> 3.0.2) 
     tzinfo (~> 0.3.29) 
    activeresource (3.2.11) 
     activemodel (= 3.2.11) 
     activesupport (= 3.2.11) 
    activesupport (3.2.11) 
     i18n (~> 0.6) 
     multi_json (~> 1.0) 
    arel (3.0.2) 
    builder (3.0.4) 
    coffee-rails (3.2.2) 
     coffee-script (>= 2.2.0) 
     railties (~> 3.2.0) 
    coffee-script (2.2.0) 
     coffee-script-source 
     execjs 
    coffee-script-source (1.4.0) 
    erubis (2.7.0) 
    execjs (1.4.0) 
     multi_json (~> 1.0) 
    hike (1.2.1) 
    i18n (0.6.1) 
    journey (1.0.4) 
    jquery-rails (2.2.1) 
     railties (>= 3.0, < 5.0) 
     thor (>= 0.14, < 2.0) 
    json (1.7.6) 
    mail (2.4.4) 
     i18n (>= 0.4.0) 
     mime-types (~> 1.16) 
     treetop (~> 1.4.8) 
    mime-types (1.21) 
    multi_json (1.5.0) 
    polyglot (0.3.3) 
    rack (1.4.5) 
    rack-cache (1.2) 
     rack (>= 0.4) 
    rack-ssl (1.3.3) 
     rack 
    rack-test (0.6.2) 
     rack (>= 1.0) 
    rails (3.2.11) 
     actionmailer (= 3.2.11) 
     actionpack (= 3.2.11) 
     activerecord (= 3.2.11) 
     activeresource (= 3.2.11) 
     activesupport (= 3.2.11) 
     bundler (~> 1.0) 
     railties (= 3.2.11) 
    railties (3.2.11) 
     actionpack (= 3.2.11) 
     activesupport (= 3.2.11) 
     rack-ssl (~> 1.3.2) 
     rake (>= 0.8.7) 
     rdoc (~> 3.4) 
     thor (>= 0.14.6, < 2.0) 
    rake (10.0.3) 
    rdoc (3.12.1) 
     json (~> 1.4) 
    sass (3.2.5) 
    sass-rails (3.2.6) 
     railties (~> 3.2.0) 
     sass (>= 3.1.10) 
     tilt (~> 1.3) 
    sprockets (2.2.2) 
     hike (~> 1.2) 
     multi_json (~> 1.0) 
     rack (~> 1.0) 
     tilt (~> 1.1, != 1.3.0) 
    sqlite3 (1.3.7-x86-mingw32) 
    thor (0.17.0) 
    tilt (1.3.3) 
    treetop (1.4.12) 
     polyglot 
     polyglot (>= 0.3.1) 
    tzinfo (0.3.35) 
    uglifier (1.3.0) 
     execjs (>= 0.3.0) 
     multi_json (~> 1.0, >= 1.0.2) 

PLATFORMS 
    x86-mingw32 

DEPENDENCIES 
    coffee-rails (~> 3.2.1) 
    jquery-rails 
    rails (= 3.2.11) 
    sass-rails (~> 3.2.3) 
    sqlite3 
    uglifier (>= 1.0.3) 

我Gemfile中有以下內容: -

source 'https://rubygems.org' 

gem 'rails', '3.2.11' 

# Bundle edge Rails instead: 
# gem 'rails', :git => 'git://github.com/rails/rails.git' 

# gem 'sqlite3' 

gem 'pg' 


# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', '~> 3.2.3' 
    gem 'coffee-rails', '~> 3.2.1' 

    # See https://github.com/sstephenson/execjs#readme for more supported runtimes 
    # gem 'therubyracer', :platforms => :ruby 

    gem 'uglifier', '>= 1.0.3' 
end 

gem 'jquery-rails' 

# To use ActiveModel has_secure_password 
# gem 'bcrypt-ruby', '~> 3.0.0' 

# To use Jbuilder templates for JSON 
# gem 'jbuilder' 

# Use unicorn as the app server 
# gem 'unicorn' 

# Deploy with Capistrano 
# gem 'capistrano' 

# To use debugger 
# gem 'debugger' 

我的包安裝顯示以下內容: -

C:\Sites\shop>bundle install 
Using rake (10.0.3) 
Using i18n (0.6.1) 
Using multi_json (1.5.0) 
Using activesupport (3.2.11) 
Using builder (3.0.4) 
Using activemodel (3.2.11) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.5) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.2.2) 
Using actionpack (3.2.11) 
Using mime-types (1.21) 
Using polyglot (0.3.3) 
Using treetop (1.4.12) 
Using mail (2.4.4) 
Using actionmailer (3.2.11) 
Using arel (3.0.2) 
Using tzinfo (0.3.35) 
Using activerecord (3.2.11) 
Using activeresource (3.2.11) 
Using bundler (1.0.22) 
Using coffee-script-source (1.4.0) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.3) 
Using json (1.7.6) 
Using rdoc (3.12.1) 
Using thor (0.17.0) 
Using railties (3.2.11) 
Using coffee-rails (3.2.2) 
Using jquery-rails (2.2.1) 
Using pg (0.14.1) 
Using rails (3.2.11) 
Using sass (3.2.5) 
Using sass-rails (3.2.6) 
Using uglifier (1.3.0) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem 
is installed. 
+1

您可以將您的Gemfile的問題? – jvnill 2013-02-12 04:22:58

+0

@jvnill我編輯了這個問題,你可以幫我 – 2013-02-12 04:29:44

+0

這就是Gemfile.lock。 Gemfile更清潔,您可以使用它嗎? – jvnill 2013-02-12 04:33:22

回答

0

請這個嘗試..

sudo apt-get install postgresql postgresql-client postgresql-contriblibpq-dev 
+0

@ vijikumar現在感謝您的工作。請告訴我如何啓動postgresql控制檯在ruby上rail.ie可以指定命令 – 2013-02-12 06:08:56

+0

謝謝你幫我出 – 2013-02-12 06:26:13

+0

如果有用請放棄。 – vijikumar 2013-02-12 07:20:50

0

你有運行bundle install
看起來好像sqlite3目前已安裝,但pg不是。

如果你移動從sqlite3pg數據,那麼看看這個railscast:Migrating to PostgreSQL

+0

是的,我已經運行捆綁安裝 C:\ Sites \ shop>捆綁安裝 ... 您的捆綁包已完成!使用'bundle show [gemname]'查看安裝了捆綁的寶石 的位置。 – 2013-02-12 04:59:29

+0

如何從rails上的ruby on rails命令提示符啓動postgresql控制檯 – 2013-02-12 05:00:55

+0

我可以在您的Gemfile中看到gem,但不是您發佈的已安裝gem列表中的gem。 – 2013-02-12 05:02:51