Postgresql & RoR issue - ruby-on-rails

I'm having issues installing the SOLIDUS gem for my rails app. I followed the instructions from GitHub but when i run the command bundle exec rake db:migrate i get the error:
mannay:testsite mannay$ bundle exec rake db:migrate
rake aborted!
PG::ConnectionBad: fe_sendauth: no password supplied
/usr/local/var/rbenv/versions/2.5.0/bin/bundle:23:in `load'
/usr/local/var/rbenv/versions/2.5.0/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I've tried adding username: mannay to my database.yml and even password: but it doesn't work. I thought maybe i've added a password that i don't remember, so i opened postgressapp, and tested
ALTER USER mannay with password 'new_password';
but it doesn't change anything.
Any ideas?

Related

ArgumentError: is not a recognized provider rake rails posgresql

I'm trying to clone and setup a rails repo.
when I run bundle exec rake db:migrate I get the following error with no user name:
rake aborted!
ArgumentError: is not a recognized providerronment.rb:5:in `<top (required)>'
It should be a problem with the provider. If I were you, I would try to set up the provider again.
provider: ENV['FOG_PROVIDER']

rake db:create - Mysql2::Error: Unknown database

I am trying to create a database using rake db:create task.
When I am running the command bundle exec rake db:create to create the database and load the schema, I get the following error:
rake aborted!
Mysql2::Error: Unknown database 'xxx_development'
My database.yml:
development:
adapter: mysql2
host: localhost
reconnect: true
username: user
password: password
pool: 50
database: xxx_development
I checked that mysql server is running and I am able to connect to it using the password/username I have in the database.yml
I also understand that I can go ahead and create the database in mysql and then run the bundle exec rake db:create but isn't the rake task db:create also creates a database in case it doesn't exists?
The rails version is 3.2.22.
and mysql2 version is 2.9.13.
Any pointers will be highly appreciated.
If you are using ohmyzsh with bundler plugin which makes rake run by default with bundle exec, you can use
unbundled_rake db:create
Ran into a similar issue on Rails 5 and the following steps helped me fix it:
Spring stop
./bin/rails db:create
I have two ideas.
Check the User permissions
When I run rake tasks, I don't use bundle exec (i.e just rake db:create)
Hope this is helpful
Try rake db:create RAILS_ENV=development hope this will work
For some reason rails db:create failed but my workaround was
to create dbs directly in mysql
sudo mysql
create database myapp_development;
create database myapp_test;
After that run as normal
rake db:migrate db:seed

Errno::EACCES: Permission denied # unlink_internal when running rake test:models

I'm playing with rails 4. I just created very simple test for my model but when I try to execute "rake test:models" I get following error:
C:\rails\project>rake test:models
DL is deprecated, please use Fiddle
rake aborted!
Errno::EACCES: Permission denied # unlink_internal - /tmp/db/new.sqlite3
C:/rails/project/test/test_helper.rb:3:in `<top (required)>'
C:/rails/project/test/models/admin_test.rb:1:in `<top (required)>'
Tasks: TOP => test:models
(See full trace by running task with --trace)
My test database configuration looks as follows:
test:
adapter: sqlite3
database: /tmp/db/new.sqlite3
pool: 5
timeout: 5000
"/tmp/db" is directory where I have full access on my personal laptop.
Any ideas what could be source of this problem?
One way I was able to get around this error was using
rake db:migrate rails_env=test
This generated the necessary migrations on my test.sqlite3
I believe the default setting for rails_env is "dev" but this may vary. I am still very new to rails but I hope this helps.
I had the same problem with my test.sqlite3 table and what worked for me was making a copy of my development.sqlite3 table and renaming it test.sqlite3. I hope this works for you.

PG::ConnectionBad Error when trying to run rake db:migrate after creating model, using postgresql

Trying to get my rails up and running but am having a problem. When creating my new rails app on the command line I ran the usual
rails new PhotoApp -d postgresql
Generated my core scaffold. Then generated a model with attributes in the terminal and that was fine. After creating my model I first ran rake db:create and that returned a long log of characters with at the top telling me FATAL: role "PhotoApp" does not exist so then I tried rake db:migrate and that didn't work either returning me
rake aborted!
PG::ConnectionBad: FATAL: role "PhotoApp" does not exist
/Users/##$%^$#/Code/Projects/PhotoApp/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
WTF is going on here?
Thanks for any help.
The error is telling you that Postgres isn't finding your app. What does your database.yml file look like?
I would first run the rake task again, using the --trace as suggested:
rake db:create --trace
That will give you a more verbose tracing, so you can try to isolate the problem.
From experience I can tell you though that 'Roles' in Postgres can be a nightmare. How did you install Postgres on your machine? HomeBrew? The Postgres App?
Please post the full trace, as well as your database.yml file. This will help better assess the problem!

Why my rake db:migrate throws error message?

I am developing Rails v2.3 application.
When I run "rake db:migrate" I got the following error message:
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted!
Access denied for user 'root'#'localhost' (using password: NO)
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
What is the reason?
It looks like your MySQL credentials are not set correctly in config/database.yml.

Resources