Reputation: 9
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
Upvotes: 0
Views: 141
Reputation: 6430
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).
Upvotes: 1