How to configure Postgresql with rails project? - ruby-on-rails

I am very new to ruby. I am trying to run BBYIDX and followed How to install BBYIDX on Windows?
When I try rake db:migrate it reproduces error as
(in /home/virinchy/BBYIDX-2/BBYIDX-master)
DEPRECATION WARNING: Rake tasks in vendor/plugins/acts_as_tsearch/tasks, vendor/plugins/acts_as_tsearch/tasks, vendor/plugins/delayed_job/tasks, vendor/plugins/nested_scenarios/tasks, vendor/plugins/rails-authorization-plugin/tasks, and vendor/plugins/rails_rcov/tasks are deprecated. Use lib/tasks instead. (called from /usr/local/rvm/gems/ruby-1.8.7-p371/gems/rails-2.3.11/lib/tasks/rails.rb:10)
rake aborted!
FATAL: password authentication failed for user "bbyidx"
FATAL: password authentication failed for user "bbyidx"
Bundle install was succesful with message as:Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
But rake db:migrate produces this error. I am running ubuntu 12.04, ruby-1.8.7, rails-2.3.11 and gem 1.5.3
How do i solve this?
Thanks in advance.

Did you set a password for your postgres user?
In your config/database.yml you should have your databases set up properly:
development:
adapter: postgresql
encoding: unicode
database: your_app_development # name your development app something
host: localhost
pool: 5
username: your_username
password: your_password # or leave blank if you didn't set a password
test:
adapter: postgresql
encoding: unicode
database: your_app_test
host: localhost
pool: 5
username: your_username
password: your_password

Related

ActiveRecord::AdapterNotSpecified: 'postgresql' database is not configured

I trying to figure out how fix the active record problem so I can push to heroku.
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
ActiveRecord::AdapterNotSpecified: 'postgresql' database is not configured. Available: ["development", "adapter", "encoding",
"database", "host", "pool", "username", "password", "production"]
development:
adapter: postgresql
encoding: unicode
database: sample_app_development
host: localhost
pool: 5
username: sample_app
password:
test:
adapter: postgresql
encoding: unicode
database: sample_app_test
host: localhost
pool: 5
username: sample_app
password:
production:
adapter: postgresql
encoding: unicode
database: sample_app_production
host: localhost
pool: 5
username: sample_app
password:
There is a space before development in the db config. I believe To fix it, simply remove space from the first line and follow the indentation.
I think you need to write this command on terminal to create you database:
rake db:create
Then run rake db:migrate to run your migrations
Remove spaces on 1st line " development:"
Make sure of the database name e.g. "sample_app_development" or just "sample_app"
gem install pg
rake db:create
rake db:migrate
First install postgresql
gem install pg
Then create project using following command:
rails new myapp -d postgresql

Rails using unkown config file for database connection

I have a weird problem.
I have set my database.yml file to use sqlite3 for all three (production, test, dev) databases
I create a new rails project with all defaults.
I fire up rail server using WEBrick
I get "ActiveRecord::ConnectionNotEstablished" error
I try $rake db:create
I get the following error:
specified 'postgresql' for database adapter, but the gem is not loaded. Add gem 'pg' to your Gemfile.
I install pg and postgres server and I get
fe_sendauth: no password supplied Error on the webpage
I try $rake db:create again on the console and get
fe_sendauth: no password supplied (which I know is a postgres password error)
It seems that Rails is choosing a different database adapter than in my database.yml file.
I don't know where it could be. It even seems to be looking for a specific database that I used in some previous project. Therefore Rails must be looking at someother config file.
Can someone help.
Add sqlite3 gem to your Gemfile:
gem 'sqlite3'
and set sqlite3 as adapter in your database.yml:
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000

Ruby on Rails error: Invalid connection "adapter"

I'm using Ruby on Rails ( rails version 2.3.4), and using pg gem (version 0.12.2) on Windows.
My database.yml file has the following content:
production:
adapter: postgresql
encoding: utf8
host: localhost
database: canvas4
username: canvas
password: canvas
port: 5433
timeout: 5000
pool: 5
queue:
adapter: postgresql
encoding: utf8
database: canvas4_queue
host: localhost
port: 5433
username: canvas
password: canvas
timeout: 5000
pool: 5
But when i run command: bundle exec rake db:initial_setup RAILS_ENV=production, the error occurs:
Invalid connection "adapter"
I've also tried with gem "activerecord-postgresql-adapter" but the same error occurs as above.
I can successfully setup with sqlite3 driver.
Do you know how to get postgresql adapter to work with rails 2.3 ?
make sure your db-adapter in database.yml is set to "postgresql". If still you have the same problem, then try using the pure-ruby adapter:
gem install postgres-pr
(make sure you uninstall the pg gem before... to avoid conflicts)
If it works, then it's a problem with the postgres gem. Anyway, for development purposes, using the pure-ruby gem is usually ok.

Can't create database in rails getting started guide

Making my way through the standard Rails "getting started", I find that when I try to execute "rake db:create", I always get the error
Could not find i18n-0.6.0 in any of the sources
Run `bundle install` to install missing gems.
here is my database.yml:
development:
adapter: mysql
database: attitude
username: attitude
password: ***
host: localhost
# 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: mysql
database: attitude
username: attitude
password: ***
host: localhost
production:
adapter: mysql
database: attitude
username: attitude
password: ***
host: localhost
i18n shows up in gem list i18n. Bundle show has i18n installed at /usr/lib/ruby/gems/1.9.1/gems/i18n-0.6.0 I've seen some related questions around stackoverflow that seemed to be the result of using sudo bundle install. I tried creating a new rails project and carefully NOT using that command, but to no avail. Do I need to entirely reinstall rails, or is my Ubuntu install ruined, or what?
Run sudo gem uninstall i18n. Then do a bundle install again (without sudo).

could not open database

I typed cd generate and then rake db:migrate, but the CMD shows that rake aborted could not open database you can refer to chap2 of the book [Ruby on Rails] OReilly Head First Rails Jan A learner's companion to Ruby on Rails 2009
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development: adapter: sqlite3 database: db/development.sqlite3 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 timeout: 5000
production: adapter: sqlite3 database: db/production.sqlite3 timeout: 5000
Sounds like your database is not properly configured. Make sure that config/database.yml matches the settings for your computer, and that you can log into the database on the host and port specified with the username and password specified.
It might help to see config/database.yml and the details of your database setup.
If your config/database.yml and adapter are configured correctly, try running rake db:create:all before running rake db:migrate

Resources