Have an error only in production! - ruby-on-rails

I'm created project. Works in development mode! Excellent!
DEVELOPMENT:
Typing : ruby lib/scripts/test_sync.rb
And my script works!
PRODUCTION:
Typing : ruby lib/scripts/test_sync.rb
Get Access denied for user 'root'#'localhost' (using password: YES)
Dont know, I did everything. grant previligies, changed password and so on... Coul someone help me, please?
UPD*
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: mysql
host: localhost
database: survey_development
username: root
password:
encoding: utf8
# 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
host: localhost
database: survey_development
username: root
password:
encoding: utf8
production:
adapter: mysql
host: survey
database: survey_production
username: survey
password:
encoding: utf8
mossad:
adapter: mysql
host: baza
database: baza_production
username: baza_survey
password:
encoding: utf8

Try adding RAILS_ENV=production

Your login/password pair is incorrect for MySql database in database.yml.
EDIT
You should remove your password row if it does not exist:
production:
adapter: mysql
host: survey
database: survey_production
username: survey
encoding: utf8

Related

Load database records to localhost

How can I make the database records that I have on my heroku app to be available also on my machine?
database.yml
development:
adapter: sqlite3
encoding: unicode
database: databasename
pool: 5
username: my_mac_username
password: #no password filled
test:
adapter: sqlite3
encoding: unicode
database: testdatabasename
pool: 5
username: my_mac_username
password: #no password filled
production:
adapter: postgresql
encoding: unicode
database: productiondatabasename
pool: 5
username: my_mac_username
password: #no password filled
I run
heroku pg:pull DATABASE_URL productiondatabasename --app my_heroku_app_name
and bunch of lines is being displayed in my terminal. But that's it. Nothing more happens. I still do not have the records available on localhost.
What am I missing here?
What I was doing wrong was the configuration of database.yml.
If using sqlite3, drop your db first, then change the development adapter to postgresql (make sure that you have installed it properly!). Then recreate the database.
After running
heroku pg:pull DATABASE_URL developmentdatabasename --app my_heroku_app_name
everything should be OK!

FATAL: Peer authentication failed for user "shop"

What I did:
sudo -u postgres psql
CREATE ROLE shop CREATEDB LOGIN PASSWORD 'kurt1245';
Then I cloned a repository from GitHub (a rails application which uses pg), bundle install, edit database.yml to write my password and now after rake db:create (also setup and migrate) doesn't work.
database.yml:
development:
adapter: postgresql
encoding: unicode
database: shop_development
pool: 5
username: shop
password: kurt1245
test:
adapter: postgresql
encoding: unicode
database: shop_test
pool: 5
username: shop
password: kurt1245
Please Add host to your database.yml file. Hope it will help you.
development:
adapter: postgresql
encoding: unicode
host: localhost
database: shop_development
pool: 5
username: shop
password: kurt1245
test:
adapter: postgresql
encoding: unicode
host: localhost
database: shop_test
pool: 5
username: shop
password: kurt1245
I've had the same error a few days back.
Edit the /etc/postgresql/$version/main/pg_hba.conf
You can check what version you're using in the psql console as select VERSION();
Inside pg_hba.conf change
local all postgres peer
to:
local all postgres md5
Peer Authentication explained
19.3.7. Peer Authentication
The peer authentication method works by obtaining the client's
operating system user name from the kernel and using it as the allowed
database user name (with optional user name mapping). This method is
only supported on local connections.

Postgres code in config.database.yml for Rails Angular app

I am following this tutorial http://asanderson.org/posts/2013/06/03/bootstrapping-angular-rails-part-1.html to create an app using rails an angular js and having issues in making postgres code work
When i run rake db :create i get this error
YAML syntax error occurred while parsing database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): mapping values are not allowed in this context at line 71 column 11
What username and password should i use in the postgres code in the database.yml file .How do i find out my postgres uername and password .posgres is already installed in the system
Here is the code in database.yml file
default: &default
adapter: postgresql
encoding: unicode
development:
<<: *default
database: blog1_development
development:
adapter: postgresql
encoding: unicode
database: blog_development
pool: 5
username: pguser
password:
test:
<<: *default
database: blog1_test
adapter: postgresql
encoding: unicode
database: blog_test
pool: 5
username: pguser
password:
I recommend you to use password create a password by
opening cmd prompt
enter this to create password
mysqladmin -u pguser password [newpassword]
after creating the password
change your database.yml file
development:
<<: *default
database: blog1_development
development:
adapter: postgresql
encoding: unicode
database: blog_development
pool: 5
username: pguser
password: [new password]
Enter the password correctly give a space after colon<:> in database.yml in password section when entering password

no records showing after migration to postgres

Just followed the "Migrating to PostgreSQL" Railscast, migrating my local sqlite3 database to postgres:
here is my database.yml file:
development:
adapter: postgresql
encoding: unicode
database: app_development
pool: 5
host: localhost
username: martinbraun
password:
test:
adapter: postgresql
encoding: unicode
database: app_test
pool: 5
username: mbraun
password:
production:
adapter: postgresql
encoding: utf8
database: app_production
pool: 5
username: mbraun
password:
My postgres server is running on postgressapp on port 5432. It tells me that it's running and I get connection to my database app_development.
However, "which psql" tells me:
/usr/bin/psql
and when I start my app, all the records are not loading, I simply see my application layout and all html stuff which is not related to any records. No error is showing up.
I have verified that my database contains data via rails console, so the migration from sqlite3 to postgres was def successful. I am just wondering why my records are not showing and what I do wrong here?

Cannot seem to use development database

I updated my database.yml file to look like so:
test:
adapter: postgresql
encoding: unicode
database: startpoint_test
hostname: localhost
pool: 5
username: postgres
password: password
development:
adapter: postgresql
encoding: unicode
database: startpoint_dev
pool: 5
username: postgres
password: password
And now it seems when I run my application, and sign up a new user the development database does not get a new user inserted into it ...
The tests all pass for signing up a new user
Have you tried using
rake db:create:all
and then
rake db:test:prepare

Resources