0

I just started building my very first Ruby on Rails application and in order for me to host it on heroku I have change my database setting in my application. I did just that by changing the database.yml file in my application. This is what I have in it now.

# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter:postgresql
  encoding:unicode
  database:dezirus_dev
  pool:5
  host:localhost
  username:postgres
  password:
  port:5432
 # 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:postgresql
  encoding:unicode
  database:dezirus_test
  pool:5
  username:postgres
  password:
  host:localhost
  port:5432

production:
  adapter:postgresql
  encoding:unicode
  database:dezirus
  pool:5
  username:postgres
  password:
  host:localhost
  port:5432

When i try to rake the DB this is the error I get.

RAHMAN@IMLDEV1-LT ~/rails-projects/dezirus
$ rake db:migrate --trace
rake aborted!
no such file to load -- pg
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.22/lib/bundler.rb:122:in `require'
/home/RAHMAN/rails-projects/dezirus/config/application.rb:7
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
/home/RAHMAN/rails-projects/dezirus/Rakefile:4
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/bin/rake:33
/usr/bin/rake:23:in `load'
/usr/bin/rake:23

Please note that the database was prebuilt using postgreSQL and i already have my tables, primary and foreign keys set. I'm not sure if maybe this is why its refusing to work or not. Any help would be really appreciated. Thanks

1
  • Did you install the pg gem? Is posgresql actually running? You need both. Commented Jul 26, 2012 at 0:19

3 Answers 3

3

First install PG in your computer, http://www.postgresql.org/download/

Try opening it with PGAdmin3 (DB administrator it comes with) and create a new BD

next in your gem file add this

gem 'pg'

run bundle install at terminal.

and here i send you an example of my DB.yml

development:
  adapter: postgresql
  encoding: unicode
  database: billy
  pool: 5
  username: postgres
  password:

You may need to configure the pg_hba.conf to login without a password in your localhost.

Sign up to request clarification or add additional context in comments.

5 Comments

I have PGIII installed on my machine and its running right now. I will change the gem file now and see if it helps. where is the pg_nba file found please?
C:\Program Files\PostgreSQL\9.1\data somewhere in that Neighbourhood
I changed the file loging level to trust so i wont need a password to access the databse. I tried a bundle install and this is the error i get now. link
what version of postgres are you using in you pc
im using V 9.1 right now. I installed it just a few days ago.
1

Add gem 'pg' to your gem file and run

bundle install

Then go here http://www.postgresql.org/download/ and install the database to your machine in order to run your app locally.

1 Comment

This is what I did initially but now when I try to bundle install I get an error saying my verion of PostgreSQL is too old or outdated. Doesn't make sense at all to me.
0

Hey guys I finally found a solution for the different issues I had. It turns out that cygwin pg gem does not support my version of PostgreSQL, I used the ruby installer and It installed without a flinch. I then used had to add this line of code to the boot.rb file

require 'yaml'
YAML::ENGINE.yamler = 'syck'

The YML file too needs to look something like this.

development:
  adapter: postgresql
  encoding: unicode
  database: dezirus_dev
  pool: 5
  username: postgres
  password:
# 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: postgresql
  encoding: unicode
  database: dezirus_test
  username: postgres
  password:
production:
  adapter: postgresql
  encoding: unicode
  database: dezirus
  username: sudo
  password: *******

I then ran the rake db:migrate command and voila :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.