我正在學習rails,當我開始並根據正在閱讀的書籍安裝sqlite3時所用的所有內容。但是,我試圖部署一個我在heroku上編寫的測試應用程序。 Heroku認爲這些應用程序運行postgresql進行開發和生產以防止微妙的錯誤。所以我決定從今以後在所有的rails應用程序中使用post gresql。rails應用默認爲sqlite3。我想將postgresql設置爲默認值_如何更改
要做到這一點我做了如下設置:
1)下載並安裝PostgreSQL的
2)的添加文件夾的路徑在我.bash_rc文件
3)安裝在PG寶石
4)一切迄今爲止是好的。然而,當我去我的應用程序的根文件夾,請嘗試以下命令:
rails generate scaffold User name:string email:string
我得到的控制檯上看到以下錯誤
rails generate scaffold User name:string email:string
invoke active_record
/Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/bundler-
1.0.22/lib/bundler/rubygems_integration.rb:143:in `block in replace_gem':
Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter`
(sqlite3 is not part of the bundle. Add it to Gemfile.) (LoadError)
from /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-
3.2.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:3:in `<top (required)>'
這告訴我,在我的Rails應用程序的默認設置是明確的sqlite3。所以我打開了我的databse.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
一切都建立了sqlite3的 我怎樣才能改變我的軌道設置,在默認情況下所有的configs數據庫是PostgreSQL的?
感謝
對不起,不完全得到你的問題。無論我做了什麼,我都列出了上述步驟。我不確定如何將每個應用程序捆綁的默認sqlite3更改爲默認PostgreSQL。我可以這樣做嗎?這將如何工作?我需要改變什麼? – banditKing 2012-04-25 22:56:43