rake db commands not working on production server - ruby-on-rails

I've just set up my production server with a postgres db, change the env to production and run bundle install --deployment. I have also set up the postgres user on my server and created the necessary db.
When I run rake db:schema:load I get the following error:
$ rake db:schema:load
-- enable_extension("plpgsql")
rake aborted!
PG::ConnectionBad: FATAL: Peer authentication failed for user "Javu"
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:87:in `connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:646:in `connection'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:661:in `block in method_missing'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:632:in `block in say_with_time'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:632:in `say_with_time'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:652:in `method_missing'
/home/rails/db/schema.rb:17:in `block in <top (required)>'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/schema.rb:41:in `instance_eval'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/schema.rb:41:in `define'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/schema.rb:61:in `define'
/home/rails/db/schema.rb:14:in `<top (required)>'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:218:in `load_schema_for'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:235:in `block in load_schema_current'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:234:in `load_schema_current'
/home/rails/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:244:in `block (3 levels) in <top (required)>'
Tasks: TOP => db:schema:load
(See full trace by running task with --trace)
rake db:migrate, rake db:create and rake db:drop returned similar errors.
My database.yml file looks like this:
default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
database: example_developement
password: ~
user: Javu
production:
<<: *default
database: example_production
user: postgres
host: localhost
test:
database: example_test
What do I have to do to fix this error and make the schema load work?

Looks like your database isn't configure to let your user access it. Take Rails out of the equation and using psql try to connect to the database using the information in your database.yml file. So something like...
psql -h localhost -U example_production
Get that working. Then Rails should be okay. You may need to tweak PostgreSQL or your database.yml so they agree on user/password/host settings.

Since the error returned suggests that you're trying to log in with the wrong user, the issue here seems to be that you aren't setting the Rails environment correctly.
Try running the command like this RAILS_ENV=production bundle exec rake db:schema:load.

Related

Rails cannot connect to mysql server windows 10

I'm trying desperately to connect my new project / any project at all to the mysql2 server. I'm not really sure whether I've correctly installed MySQL server 5.7.21 or not but perhaps someone could advise.
I'm running ruby 2.3, rails 5.0.7 and mysql2 0.5.1. I definitely have mysql2 in my gemfile. I am running this on my 64-bit laptop with Windows 10
Every time I run a rails db:schema:dump from my project file in the command prompt, it shows this error:
C:\Users\MR_ra\Documents\Sites\matt_radin_cms>rails db:schema:dump --trace
** Invoke db:schema:dump (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:schema:dump
rails aborted!
Mysql2::Error::ConnectionError: Can't connect to MySQL server on 'localhost'
(10061)
C:/Ruby23/lib/ruby/gems/2.3.0/gems/mysql2-0.5.1-x86-mingw32/lib/mysql2/client.rb:90:in `connect'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/mysql2-0.5.1-x86-mingw32/lib/mysql2/client.rb:90:in `initialize'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `new'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `mysql2_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:729:in `new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:773:in `checkout_new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:752:in `try_to_checkout_new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:713:in `acquire_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:490:in `checkout'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:883:in `retrieve_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:128:in `retrieve_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:91:in `connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:241:in `block (4 levels) in <top (required)>'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:240:in `open'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:240:in `block (3 levels) in <top (required)>'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `block in execute'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `each'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `execute'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
C:/Ruby23/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:193:in `invoke_with_call_chain'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:182:in `invoke'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `each'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:110:in `top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:14:in `block in run_rake_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:11:in `run_rake_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:schema:dump
Currently my databases.yml file is looking like this:
default: &default
adapter: mysql2
host: localhost
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: ***********
password: ***********
My question is also to answer what does the localhost 10061 refer to?
If your databases.yml file only like this which is you shared your question then you update little bit like this
default: &default
adapter: mysql2
host: localhost
encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: xxxxxxxxxxx
password: xxxxxxxxxxx
#=> if live server
#=> socket: /var/run/mysqld/mysqld.sock
#=> for developmen
development:
<<: *default
database: project_development
#=> for test
test:
<<: *default
database: project_test
#=> for production
production:
<<: *default
database: project_production
username: xxxxxxxxxx
password: xxxxxxxxxx
then rails db:create
Actually, that is my configuration which already working
Note: If you developing locally and not set any password for mysql then username and password will look like this
username: root
password:
If you use WAMP or XAMPP you must run this before running rails command. The WAMP is recommended for windows.
that means by default username is root and password is empty.
You can by default set up this configuration if you will run this command for creating a Rails project
rails new project_name -d mysql

Cannot connect rails and mysql2

So I'm trying to perform a simple database dump from the command prompt for the first time and the rails command keeps aborting with an error. This is running Ruby 2.3.0 with rails 5.0.7 and mysql 0.5.0.
C:\Users\MR_ra\Documents\Sites\matt_radin_cms>rails db:schema:dump --trace
** Invoke db:schema:dump (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:schema:dump
rails aborted!
NameError: uninitialized constant Mysql2::Client::REMEMBER_OPTIONS
C:/Ruby23/lib/ruby/gems/2.3.0/gems/mysql2-0.5.0-x86-mingw32/lib/mysql2/client.rb:14:in `default_query_options'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/mysql2-0.5.0-x86-mingw32/lib/mysql2/client.rb:25:in `initialize'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `new'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/mysql2_adapter.rb:25:in `mysql2_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:729:in `new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:773:in `checkout_new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:752:in `try_to_checkout_new_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:713:in `acquire_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:490:in `checkout'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:883:in `retrieve_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:128:in `retrieve_connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:91:in `connection'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:241:in `block (4 levels) in <top (required)>'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:240:in `open'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/railties/databases.rake:240:in `block (3 levels) in <top (required)>'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `block in execute'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `each'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `execute'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
C:/Ruby23/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:193:in `invoke_with_call_chain'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:182:in `invoke'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:160:in `invoke_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `each'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block in top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:125:in `run_with_threads'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:110:in `top_level'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:14:in `block in run_rake_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/rake_proxy.rb:11:in `run_rake_task'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
C:/Ruby23/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:schema:dump
It's looking like no Mysql installed in your machine or adapter setting is wrong.
First install mysql server in your machine.
after that install mysql2 gem by below command or adding in application gemfile
gem install mysql2
gem 'mysql2'
then do below setting for your adapter
default: &default
adapter: mysql2
username: xxxxx
password: xxxxx
host: localhost
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
Hope this will help you out.
I think the problem with mysql2 gem version, you can define the version like this
gem 'mysql2', '~> 0.3.17'
then bundle install, it solved the problem on my hand.
The database.yml
default: &default
adapter: mysql2
host: localhost
encoding: unicode
username: root
password: #=> if you use password to your local databse then use otherwise empty this
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: database_development

Rails and Azure: TinyTds::Error: Adaptive Server connection failed

I'm trying to configure my Rails project with SQL on Azure. I'm using Mac OS X 10.11.
This is part of my config/database.yml:
staging:
adapter: sqlserver
mode: dblib
host: db-staging.database.windows.net
port: 1433
database: db-staging
username: myuser#db-staging
password: mypass
timeout: 5000
azure: true
When I run tsql seems like is everything ok:
$ tsql -H db-staging.database.windows.net -U myuser -P 'mypass' -v -p 1433 -D db-staging
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Setting db-staging as default database in login packet
Changed database context to 'db-staging'.
Changed language setting to us_english.
1>
But when I run rake db:migrate I receive this error TinyTds::Error: Adaptive Server connection failed.
Here is the complete trace:
$ rake db:migrate RAILS_ENV=staging --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:
* development - set it to false
* test - set it to false (unless you use a tool that preloads your test environment)
* production - set it to true
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
TinyTds::Error: Adaptive Server connection failed
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/tiny_tds-0.7.0/lib/tiny_tds/client.rb:74:in `connect'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/tiny_tds-0.7.0/lib/tiny_tds/client.rb:74:in `initialize'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-sqlserver-adapter-4.2.10/lib/active_record/connection_adapters/sqlserver_adapter.rb:311:in `new'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-sqlserver-adapter-4.2.10/lib/active_record/connection_adapters/sqlserver_adapter.rb:311:in `dblib_connect'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-sqlserver-adapter-4.2.10/lib/active_record/connection_adapters/sqlserver_adapter.rb:302:in `connect'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-sqlserver-adapter-4.2.10/lib/active_record/connection_adapters/sqlserver_adapter.rb:58:in `initialize'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-sqlserver-adapter-4.2.10/lib/active_record/sqlserver_base.rb:17:in `new'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-sqlserver-adapter-4.2.10/lib/active_record/sqlserver_base.rb:17:in `sqlserver_connection'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/connection_handling.rb:87:in `connection'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/migration.rb:912:in `initialize'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/migration.rb:819:in `new'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/migration.rb:819:in `up'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/migration.rb:797:in `migrate'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/activerecord-4.2.3/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `call'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `block in execute'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `each'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `execute'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:187:in `block in invoke_with_call_chain'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:180:in `invoke_with_call_chain'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/task.rb:173:in `invoke'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:150:in `invoke_task'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `each'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:106:in `block in top_level'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:115:in `run_with_threads'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:100:in `top_level'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:78:in `block in run'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/lib/rake/application.rb:75:in `run'
/Users/monteirobrena/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/gems/2.0.0/gems/rake-11.1.2/bin/rake:33:in `<top (required)>'
/Users/monteirobrena/.rvm/gems/ruby-2.0.0-p481/bin/rake:23:in `load'
/Users/monteirobrena/.rvm/gems/ruby-2.0.0-p481/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate
I saw other questions like this, but did not help me:
TinyTds::Error: Adaptive Server connection failed
TinyTds Error: Adaptive Server connection timed out
[Updated]
I tried do exactly like here:
https://github.com/Azure/azure-sql-database-samples/tree/master/Ruby%20on%20Rails/Sample%20Mac
Following this post I found the correct configurations to set in my config/database.yml.
https://azure.microsoft.com/en-us/documentation/articles/sql-database-develop-ruby-simple-mac-osx/
staging:
adapter: sqlserver
username: 'username#database'
password: 'password'
host: 'db-staging.database.windows.net'
port: 1433
database: 'db-staging'
azure: true
And add this gems im my Gemfile:
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'
Now when I access my project folder and run rails s I can connect with my database and everything work fine. But, if I run my project with Puma and Nginx, I receive this error:
TinyTds::Error (Adaptive Server connection failed):
[/Updated]
I need install FreeTDS by myself, if apt-get we can't pass the arguments of compilation:
wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
$ tar -zxvf freetds-stable.tgz
$ cd freetds-0.91/
$ ./configure --with-tdsver=8.0 --with-openssl=/usr/bin
$ make
$ sudo make install
And now I can access my database:
$ tsql -C # OK!
$ TDSVER=8.0 tsql -H mydb.database.windows.net -p 1433 -U myuser#mydb -P mypassword -D mydb
And everything works when I run and access with Puma, Nginx and Capistrano.
See more here:
https://github.com/rails-sqlserver/tiny_tds/issues/266

Why is rails console ignoring my config/database.yml development: settings?

My database.yml file specifies a non-default database: and no explicit username:. If I use rails c and try to access anything it fails with, e.g.:
2.2.2 :001 > User.connection
ActiveRecord::NoDatabaseError: FATAL: role "scope" does not exist
If I try to explicitly connect using my :development settings I see:
2.2.2 :005 > ActiveRecord::Base.establish_connection :development
=>
#<ActiveRecord::ConnectionAdapters::ConnectionPool:...
#config={:adapter=>"postgresql", :encoding=>"unicode", :database=>"scope", :pool=>5, :timeout=>5000, :port=>5432, :username=>"scope", :password=>"...", :host=>"127.0.0.1"},
...
So it's clearly ignoring my custom database and my own username. Oddly enough, if I rename the yaml block from development: to anything else, e.g. staging:, I can connect fine with a ActiveRecord::Base.establish_connection :staging and access my models.
Anyone know what could be going on? I do not have a DATABASE_URL environment variable set, so that can't be overriding things. What else could be causing this behavior?
Here's the actual yml:
development:
adapter: postgresql
encoding: unicode
database: mydb_development
pool: 5
timeout: 5000
port: <%= ENV["BOXEN_POSTGRESQL_PORT"] || 5432 %>
And a stacktrace:
2.2.2 :002 > User.count
ActiveRecord::NoDatabaseError: FATAL: role "scope" does not exist
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:665:in `rescue in connect'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:655:in `connect'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
from /Users/me/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
from /Users/me/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activerecord-4.2.3/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
... 11 levels...
from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-4.2.3/lib/rails/commands/console.rb:9:in `start'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-4.2.3/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-4.2.3/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
from /Users/me/Documents/projects/deliveries/bin/rails:8:in `<top (required)>'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/me/.rvm/gems/ruby-2.2.2/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:268:in `load'
from /Users/me/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/me/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'2.2.2 :003 >
UPDATE
Using a new shell and connecting to the console seemed to magically fix things. I still don't know what originally corrupted things though...
Try This:
development:
adapter: postgresql
encoding: unicode
database: XXX_development
host: localhost
pool: 5
username: yourusername
password: yourpassword

In ruby rake db:migrate show the password failure

I am using rails with postgresql which is on remote machine. I have edited database.yml file according to the requirement.but when i run rake db:migrate it shows password failure.. but the same password works with the psql command..
the error when i run rake db:migrate is:
root#vdimc04 My_Postgres]# rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
fe_sendauth: no password supplied
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `connect'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:326:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/migration.rb:662:in `initialize'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/migration.rb:570:in `new'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/migration.rb:570:in `up'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/migration.rb:551:in `migrate'
/usr/local/rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.9/lib/active_record/railties/databases.rake:179:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:227:in `call'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:227:in `block in execute'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:222:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:222:in `execute'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:159:in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/task.rb:152:in `invoke'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:141:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:99:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:99:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:99:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:108:in `run_with_threads'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:93:in `top_level'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:71:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:158:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/lib/rake/application.rb:68:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/rake-10.0.2/bin/rake:37:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/bin/rake:19:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:migrate
** my database.yml file**
development:
adapter: postgresql
encoding: unicode
database: db_pchamara
pool: 5
username: db_test_user
password: password
host: 192.168.1.101
port: 5432
test:
adapter: postgresql
encoding: unicode
database: db_pchamara_test
pool: 5
username: db_test_user
password: password
production:
adapter: postgresql
encoding: unicode
database: db_pchamara_production
pool: 5
username: db_test_user
password: password
Guys I got answer to my question...
When we start a new project with rails command like 'rails new demo' we have to include '--database=postgresql'. Then only the pg gem will gets to the bundle.. If it is not declared the pg gem will not comes to bundle..
And what i did in database.yml file is also correct. Everything is fine there...
When we use the database of postgresql to rails, we have to make some modifications to pg_hba.conf that is located in the lib directory..
I made some modifications there at my ip to TRUST where before it is md5..
we Can use both TRUST and md5.
md5- requires a passowrd to connect to database
trust- not requires a password
thats it.. as ususal include password to database.yml file.
Now the server runs without any error...
THANKS TO EVERYONE WHO HELPED ME TO FIGURE OUT THIS PROBLEM

Resources