Reputation: 115
I ran the rails server from my application directory. But when I tried to do a request from the browser with
http://localhost:3000
I get the following error:
*Psych::BadAlias
Cannot load Rails.application.database_configuration
: Unknown alias: default*
Upvotes: 2
Views: 6537
Reputation: 1738
The pysch gem has a breaking change where it will not allow loading YAML files containing aliases by default.
Here's an example of a YAML:
default: &default
adapter: postgresql
Since you don't control the code in question you can either modify your yml files (e.g. database.yml) to not use aliases or monkey patch the psych code.
There is a lot more detail in this answer, even though the error message has been updated.
visit_Psych_Nodes_Alias: Unknown alias: default (Psych::BadAlias)
Upvotes: 0
Reputation: 484
This happens because the password DB has some special character if you used rbenv-vars Plugin, change the password without special character.
Upvotes: 0
Reputation: 5639
This happens because the ruby-plugin for netbeans messes the database.yml file when creating project from existing source. It replaces the comment about sqlite3 to mysql, but even worse it erases the first definition block which is 'default'
So simply insert
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
at the beginning of the database.yml and you'll be fine
Upvotes: 3
Reputation: 115
The content of the database.yml file is:
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/development.sqlite3_test
production:
<<: *default
database: db/development.sqlite3_production
I am using netbeans as text editor and there is a error at the top of the file indicating:
ComposerException null we had this found undefined alias default
Thank you
Upvotes: 0
Reputation: 18037
This is being caused by an invalid alias in your database.yml
file. You most likely have something that looks close to this... but not quite:
defaults: &defaults
adapter: mysql2
username: root
password:
host: localhost
timeout: 5000
development:
database: app_name_development
<<: *defaults
In this, &defaults
defines the alias that your error is talking about. Make your database.yml
look more like this syntax and you should be set. Or, post your database.yml
file here and we can help you fix it specifically if needed.
Upvotes: 2