I'm trying to build a rails app and deploy it to heroku, I'm very new to all of this, and I'm following this Getting started on Heroku I first installed heroku and postgresql, in the command line (windows 10) I run this command heroku login then rails new weather --database=postgresql then I cd into the weather folder, I run rails db:create and I get this error fe_sendauth: no password supplied Couldn't create 'weather_development' database. Please check your configuration. rails aborted! PG::ConnectionBad: fe_sendauth: no password supplied bin/rails:4:in `<main>' Tasks: TOP => db:create
what to configure, and where are the configurations files?
Installing postgresql locally on Ubuntu:
gemfile:
gem "pg"
console:
sudo apt install postgresql libpq-dev
sudo su postgres
createuser --interactive --pwprompt
username
password
start server:
rails db:create db:migrate
rails s
don't have sqlite and pg installed in one app at the same time.
if you have a postgresql database working in development environment, it will work in heroku for sure.
after pushing to heroku, don't forget to run heroku run rails db:migrate
Related
I have a live app on Heroku, and I'm attempting to build a database for my staging app using the following command:
heroku run rake db:schema:load --remote staging
The first roadblock I hit is this error:
ActiveRecord::NoEnvironmentInSchemaError:
Environment data not found in the schema. To resolve this issue, run:
bin/rails db:environment:set RAILS_ENV=production
After running this command, I get a second error:
rails aborted!
ActiveRecord::NoDatabaseError: FATAL: role "appname" does not exist
Not great at dealing with database issues. Any help would be appreciated.
This is a common thing you may have to provision a new database you can check the following link
https://devcenter.heroku.com/articles/postgres-logs-errors#fatal-role-role-name
But for locally you can do the following
sudo -u postgres createuser --superuser appname
or
createuser -P -d -e appname
I was using sqlite but switched to pg for some reasons.
I included pg gem in the makefile and made changes in the config/environments.
When I started migrating the data using rake db:migrate , I’m getting this error.
PG::ConnectionBad: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I've gone through all the posts related to this but did not find a solution.
I'm using ruby 2.1.5 and rails 4.2.0.
sudo /etc/init.d/postgresql start
or
sudo /etc/init.d/postgresql restart
Both should work just fine
If you still get an error you should fix the config/database.yml file one way to go about this is simply create a new project
rails new yourapp -d postgresql
then just copy the database.yml file
if you need to create an new user and password
sudo -u postgres createuser john -s
If you would like to set a password for the user, you can do the following
sudo -u postgres psql
postgres=# \password john
Most of this is from gorails
You need to start your PG server:
$ postgres -D /usr/local/pgsql/data
http://www.postgresql.org/docs/9.1/static/server-start.html
I have postgresql setup for my production schema in database.yml. I was able to successfully run RAILS_ENV=production rake db:migrate but when I do do RAILS_ENV=production rails console, it hangs. Never gives me the console prompt.
I've also tried bundle exec rails console production but didn't help.
Output:
Connecting to database specified by database.yml
...hangs after this.
Running rails 3.2.11 on ruby 2.1.2. I have rbenv and rbenv-gemsets installed.
To run the rails console in the production environment you need to pass the name of the environment after the command. The actual command is as follows.
rails console production
If that doesn't work, try restarting your PostgreSQL server and try again. It could be that you have crossed the number of possible connections with the PostgreSQL database.
Im trying to deploy with Mina. I get stuck on database migrations because it say the database does not exist.
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
-----> Migrating database
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: database "production" does not exist
Run `$ bin/rake db:create db:migrate` to create your database
How can I create the database using mina or ssh? im using ubuntu 14.04 on digitalocean
For a new project I'm trying to run postgres locally.
Mac Lion has Postgres installed (9.1.2). I modified my path in .bash_profile (per another SO thread) so now I have no trouble creating a database or user using the psql utility.
I uninstalled and re-installed the pg gem (0.13.2) using env ARCHFLAGS="-arch x86_64" gem install pg per the excellent blog at http://blog.willj.net/2011/05/31/setting-up-postgresql-for-ruby-on-rails-development-on-os-x/
My Gemfile uses the pg gem for development, test, and production. I've run bundle install.
My database.yml looks like this (and the username and database names are correct and I verified I can access the database fr that username using the psql utility):
development:
adapter: postgresql
encoding: unicode
database: ddchart_development
pool: 5
username: ddchart
password:
(same for test and production, except _test and _production. Password is blank, right?)
When I run bundle exec rake db:migrate it aborts:
rake aborted!
couldn't parse YAML at line 8 column 10
Any help would be appreciated!
If you pasted the code correctly, there are errors in the code. For example, there's only one space before "adapter", but two before following lines.
In YAML, indentation matters.