Starting rails. postgresql_adapter.rb FATAL - ruby-on-rails

Hi I am new in Ruby on Rails.
I've installed Rails and everything was working fine.
Then I changed database from SQLite to Postgre (because Heroku don't support it),did git push to Heroku.Everything was fine.
But when I restarted my local repository,it showed me this(on local repo):
user~:$ rails server
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:1215:in `initialize': FATAL: role "roma" does not exist (PG::ConnectionBad)
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:1215:in `new'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:1215:in `connect'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:323:in `initialize'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:27:in `new'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/postgresql_adapter.rb:27:in `postgresql_connection'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
from /usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
from /usr/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /usr/lib/ruby/vendor_ruby/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /usr/lib/ruby/vendor_ruby/active_record/railtie.rb:88:in `block in <class:Railtie>'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:30:in `instance_exec'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:30:in `run'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:55:in `block in run_initializers'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:54:in `each'
from /usr/lib/ruby/vendor_ruby/rails/initializable.rb:54:in `run_initializers'
from /usr/lib/ruby/vendor_ruby/rails/application.rb:136:in `initialize!'
from /usr/lib/ruby/vendor_ruby/rails/railtie/configurable.rb:30:in `method_missing'
from /home/roma/Templates/first_app/config/environment.rb:5:in `<top (required)>'
from /home/roma/Templates/first_app/config.ru:3:in `require'
from /home/roma/Templates/first_app/config.ru:3:in `block in <main>'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in `instance_eval'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in `initialize'
from /home/roma/Templates/first_app/config.ru:in `new'
from /home/roma/Templates/first_app/config.ru:in `<main>'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:49:in `eval'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:49:in `new_from_string'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:40:in `parse_file'
from /usr/lib/ruby/vendor_ruby/rack/server.rb:277:in `build_app_and_options_from_config'
from /usr/lib/ruby/vendor_ruby/rack/server.rb:199:in `app'
from /usr/lib/ruby/vendor_ruby/rails/commands/server.rb:46:in `app'
from /usr/lib/ruby/vendor_ruby/rack/server.rb:314:in `wrapped_app'
from /usr/lib/ruby/vendor_ruby/rack/server.rb:250:in `start'
from /usr/lib/ruby/vendor_ruby/rails/commands/server.rb:70:in `start'
from /usr/lib/ruby/vendor_ruby/rails/commands.rb:55:in `block in <top (required)>'
from /usr/lib/ruby/vendor_ruby/rails/commands.rb:50:in `tap'
from /usr/lib/ruby/vendor_ruby/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
What can be cause of that?
Sorry for bad English.
In addition this is my database.yml file
development:
adapter: postgresql
database: my_database_development
pool: 5
timeout: 5000
test:
adapter: postgresql
database: my_database_development
pool: 5
timeout: 5000
production:
adapter: postgresql
database: my_database_development
pool: 5
timeout: 5000

Based on your error, you need to make a the user roma for your rails server to use to connect to your database. You can do this by using createuser to make your user defined in your database.yml. You may need to first do:
sudo su - postgres
createuser -P -s -e {your_machine_username}
but only if createuser throws an error with a normal createuser -P -s -e {user_defined_in_databaseyml}.
Then you can exit that user (exit will drop su) and do:
createuser -P -s -e {user_defined_in_databaseyml}
Then you should be able to rails s just fine (make sure you rake your db related tasks first).

Related

rescue in check_for_missing_columns': uninitialized constant ActiveRecord::NoDatabaseError (NameError)

I'm trying to run this application via cloud9.io. I'm not a programmer. Tried everything I could comprehend, but hit a dead end. I try to run the app, but it throw an error. Here is the output:
Digest::Digest is deprecated; use Digest
Auto-loading of `.env.development` will be removed in 1.0. See https://github.com/bkeepers/dotenv-deployment if you would like to continue using this feature.
=> Booting WEBrick
=> Rails 3.2.22 application starting in development on http://0.0.0.0:8080
=> Call with -d to detach
=> Ctrl-C to shutdown server
Connecting to database specified by database.yml
Exiting
/usr/local/rvm/gems/ruby-2.1.3/gems/doorkeeper-2.0.1/lib/doorkeeper/config.rb:29:in `rescue in check_for_missing_columns': uninitialized constant ActiveRecord::NoDatabaseError (NameError)
from /usr/local/rvm/gems/ruby-2.1.3/gems/doorkeeper-2.0.1/lib/doorkeeper/config.rb:21:in `check_for_missing_columns'
from /usr/local/rvm/gems/ruby-2.1.3/gems/doorkeeper-2.0.1/lib/doorkeeper/config.rb:11:in `configure'
from /home/ubuntu/workspace/config/initializers/doorkeeper.rb:6:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/engine.rb:593:in `block (2 levels) in <class:Engine>'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/engine.rb:592:in `each'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/engine.rb:592:in `block in <class:Engine>'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/initializable.rb:30:in `run'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/initializable.rb:54:in `each'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/application.rb:136:in `initialize!'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/ubuntu/workspace/config/environment.rb:5:in `<top (required)>'
from /home/ubuntu/workspace/config.ru:17:in `block in <main>'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/builder.rb:51:in `instance_eval'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/builder.rb:51:in `initialize'
from /home/ubuntu/workspace/config.ru:in `new'
from /home/ubuntu/workspace/config.ru:in `<main>'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/builder.rb:40:in `eval'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/builder.rb:40:in `parse_file'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/server.rb:200:in `app'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands/server.rb:46:in `app'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/server.rb:304:in `wrapped_app'
from /usr/local/rvm/gems/ruby-2.1.3/gems/rack-1.4.7/lib/rack/server.rb:254:in `start'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands/server.rb:70:in `start'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands.rb:55:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands.rb:50:in `tap'
from /usr/local/rvm/gems/ruby-2.1.3/gems/railties-3.2.22/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Process exited with code: 1
[K
Process exited with code: 1
Here's the contents of database.yml
development:
adapter: postgresql
encoding: utf8
database: bikereg
username: postgres
password: !q2w3e4r5t
pool: 5
test:
adapter: postgresql
database: bikereg_test
staging:
adapter: postgresql
database: bikereg_staging
production:
adapter: postgresql
database: bikereg_production
pool: 25
Any idea how to fix it?

During the command "RAILS_ENV=production script/rails server" I'm getting the following error

/usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:205:in `parse': (<unknown>): could not find expected ':' while scanning a simple key at line 4 column 3 (Psych::SyntaxError)
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:205:in `parse_stream'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:153:in `parse'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:129:in `load'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/mongoid-2.4.5/lib/mongoid/railtie.rb:83:in `block in <class:Railtie>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /opt/graylog2-web-interface/config/environment.rb:6:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
from /opt/graylog2-web-interface/config.ru:3:in `block in <main>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /opt/graylog2-web-interface/config.ru:in `new'
from /opt/graylog2-web-interface/config.ru:in `<main>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.12/lib/rails/commands/server.rb:46:in `app'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.12/lib/rails/commands/server.rb:70:in `start'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.12/lib/rails/commands.rb:55:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/railties-3.2.12/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Hi guys I got the solution.
The problem is with config/mongoid.yml file where I kept parameter like below
production:
host: localhost
port: 27017
username:user #There should be a space between : and user.
password: pwd
database: prod
Correct Way of configuration
production:
host: localhost
port: 27017
username: user
password: pwd
database: prod
Did you want start rails server in production environment? Could following work:
rails s --environment PRODUCTION

Rails - Postgres - could not connect to server: Connection refused (PG::ConnectionBad)

Yesterday I've install Postgres and pgAdminIII, all worked correctly, but after reload it stopped working. After rails server I've got error message:
=> Booting Thin
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `initialize': could not connect to server: Connection refused (PG::ConnectionBad)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `new'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `connect'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:324:in `initialize'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
from /home/home/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
from /home/home/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88:in `block in <class:Railtie>'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/home/Projects/mostdance/config/environment.rb:5:in `<top (required)>'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from /home/home/Projects/mostdance/config.ru:3:in `block in <main>'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /home/home/Projects/mostdance/config.ru:in `new'
from /home/home/Projects/mostdance/config.ru:in `<main>'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from /home/home/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
This is my database.yml file:
development:
host: localhost
adapter: postgresql
encoding: unicode
database: mydb
pool: 5
timeout: 5000
username: postgres
password: password
min_messages: WARNING
test:
host: localhost
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: postgresql
encoding: unicode
database: mydb
pool: 5
timeout: 5000
username: postgres
password: password
host: 127.0.0.1
port: 5432
min_messages: WARNING
Also I try to run server Postgres:
su postgres /etc/init.d/postgresql start
Password:
* Starting PostgreSQL 9.1 database server * Use of uninitialized value $info{"pgdata"} in -d at /usr/bin/pg_ctlcluster line 331.
Use of uninitialized value $info{"pgdata"} in concatenation (.) or string at /usr/bin/pg_ctlcluster line 332.
Error: is not accessible or does not exist
Also I don't know why, but now rails server put this error:
=> Booting Thin
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/home/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1216:in `initialize': FATAL: Peer authentication failed for user "postgres" (PG::ConnectionBad)
Please, help me! If you need more information - write into comments and I will update my question
When I have had this issue in the past there are often a few things I can do to get it running, most of them seem simple, but I'm mighty forgetful --
sometimes I haven't actually created the DB after switching to postgres
bundle exec rake db:create
and then get all of my tables in there --
bundle exec rake db:migrate
other times I need to double check and make sure the PG gem is installed
gem install pg
If you are on Mac. then try reinstalling Postgresapp and then restarting everything. Make sure to import the database again.
If you are on Linux the reinstall Postgres and then restart everything.

Starting rails server having error for a mysql project

i'm using ruby version 1.9.3 p448 and rails version 3.2.13
all of my gems are upto date.
i create a project with the following code rails new simple_cms -d mysql
but when I start rails server with code rails s / rails server
I got the following error
wasif#Bayaw:~/projects/Sites/simple_cms$ rails s
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/mysql2-0.3.13/lib/mysql2/client.rb:58:in `connect': Access denied for user 'root'#'localhost' (using password: NO) (Mysql2::Error)
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/mysql2-0.3.13/lib/mysql2/client.rb:58:in `initialize'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
from /home/wasif/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
from /home/wasif/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88:in `block in <class:Railtie>'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/wasif/projects/Sites/simple_cms/config/environment.rb:5:in `<top (required)>'
from /home/wasif/projects/Sites/simple_cms/config.ru:3:in `require'
from /home/wasif/projects/Sites/simple_cms/config.ru:3:in `block in <main>'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /home/wasif/projects/Sites/simple_cms/config.ru:in `new'
from /home/wasif/projects/Sites/simple_cms/config.ru:in `<main>'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from /home/wasif/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
please help me how to resolve this error... thanks!
Looks like the password is not set.
In your database.yml you should specify the password for your DB. E.g: if you have set the password on your devlopment pc to: root, it should look like this:
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: your_db_name
pool: 5
username: root
password: root
socket: 'depending on your os something like:' /tmp/mysql.sock
Also I recommend not to check this file into your VCS. Make a copy of it, call it database.example.yml and put in there your config and a placeholder for the password.

Rails server exiting immediately after starting

I'm new to rails and I downloaded a repo from github which I'm trying to work on.
When I try to start rails s this happen, same thing happens for rails c:
=> Booting WEBrick
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application/configuration.rb:115:in `read': No such file or directory - /Users/falk/Desktop/parkbuddy/config/database.yml (Errno::ENOENT)
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application/configuration.rb:115:in `database_configuration'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.12/lib/active_record/railtie.rb:78:in `block (2 levels) in <class:Railtie>'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:25:in `each'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-3.2.12/lib/active_record/railtie.rb:74:in `block in <class:Railtie>'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/falk/Desktop/parkbuddy/config/environment.rb:5:in `<top (required)>'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
from /Users/falk/Desktop/parkbuddy/config.ru:3:in `block in <main>'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /Users/falk/Desktop/parkbuddy/config.ru:in `new'
from /Users/falk/Desktop/parkbuddy/config.ru:in `<main>'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands/server.rb:46:in `app'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands/server.rb:70:in `start'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands.rb:55:in `block in <top (required)>'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
from /Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have tried googling a solution but I can't find anything.
Your first line of errors says you don't have config/database.yml file.
create a database.yml file inside you applications config directory and
in database.yml file
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
test:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
The first line is showing you your problem:
/Users/falk/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/application/configuration.rb:115:in `read': No such file or directory - /Users/falk/Desktop/parkbuddy/config/database.yml (Errno::ENOENT)
The config/database.yml file is not present in your Rails app. Check with the app's documentation to see what it suggest you do about database configuration.
I hava the same problem but with a different answer...
fabio#ubuntu:~/Desktop/teste/foo$ rails server
=> Booting WEBrick
=> Rails 4.0.0 application starting in development on localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:191:in `normalize_conditions!': You should not use the `match` method in your router without specifying an HTTP method. (RuntimeError)
If you want to expose your action to both GET and POST, add `via: [:get, :post]` option.
If you want to expose your action to GET, use `get` in the router:
Instead of: match "controller#action"
Do: get "controller#action"
from /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:67:in `initialize'
from /var/lib/gems/1.9.1/gems/actionpack-4.0.0/lib/action_dispatch/routing/mapper.rb:1438:in `new'
...

Resources