-
-
Notifications
You must be signed in to change notification settings - Fork 67
Development
Source repository: https://github.com/heartcombo/devise
ref: https://github.com/heartcombo/devise/wiki/How-To:-Create-custom-layouts
Use layout
to override the default one for a single controller (extending from Devise::RegistrationsController
).
If needed, it can also be constrained with only
to a subset of views:
class Users::RegistrationsController < Devise::RegistrationsController
layout 'without_sidebar', only: :edit
end
If you get the following error upon starting the Rails server or trying to run the entrypoint.sh script:
There is an issue connecting to your database with your username/password, username: <your username>.
First, check the configuration, specifically that:
-
the credentials provided in the docker/env file are correct (
MYSQL_USER
should also match the username from the error message). If you haven't changed the defaults, they should look like this:MYSQL_ROOT_PASSWORD=qpixel MYSQL_DATABASE=qpixel MYSQL_USER=qpixel MYSQL_PASSWORD=qpixel
-
the credentials in the docker/env file match the ones in config/database.docker.yml. The default section should look like this (irrelevant keys omitted for brevity). Note that
username
should matchMYSQL_USER
andpassword
should matchMYSQL_PASSWORD
:default: &default username: qpixel password: qpixel
-
the user whose username was in the error message (and that matches
username
andMYSQL_USER
) exists and has the grants necessary to connect to the database and manage it. First, connect to the database container, for example, withdocker exec -it qpixel-db-1 bash
. Once inside, enter the MySQL CLI as root (mysql -u root -p
). After that, confirm that you areroot
withselect user(), current_user();
The output should look like this:+----------------+----------------+ | user() | current_user() | +----------------+----------------+ | root@localhost | root@localhost | +----------------+----------------+
If you are root, switch to the
mysql
database (use mysql;
) and check if the user that is supposed to connect to the database exists, has a correct authentication plugin, and host by running aselect host, user, plugin from user;
query. The output should look something like this (irrelevant users omitted for brevity). The correct output must have a user matching the one fromMYSQL_USER
[docker/env] andusername
[config/database.docker.yml] with host set to%
and authentication plugin set tomysql_native_password
:+------------------+-----------+-----------------------+ | user | host | plugin | +------------------+-----------+-----------------------+ | qpixel | % | mysql_native_password | | root | % | caching_sha2_password | | root | localhost | mysql_native_password | +------------------+-----------+-----------------------+
If there is no such user, create one with
create user '<your username>'@'%' identified with mysql_native_password by '<your password>';
(note that the password must matchMYSQL_PASSWORD
[docker/env] andpassword
[config/database.docker.yml]). After the user is created, add the necessary grants to it:grant usage on *.* to '<your username>'@'%'; grant all privileges on qpixel.* to '<your username>'@'%'; grant all privileges on qpixel_dev.* to '<your username>'@'%'; grant all privileges on qpixel_test.* to '<your username>'@'%';
For the grants to take effect immediately, run
flush privileges;
afterwards. At this point, the error should be resolved. Restart the services to be sure everything's applied correctly - the user should successfully connect to the database.If the user does exist, check the grants with
show grants for '<your username>'@'%'
. If the output doesn't look like below, you'll need to add the missing grants (see above) depending on what's amiss (note that there should be aUSAGE
grant on*.*
andALL PRIVILEGES
grant for theqpixel
,qpixel_dev
, andqpixel_test
databases):+---------------------------------------------------------+ | Grants for qpixel@% | +---------------------------------------------------------+ | GRANT USAGE ON *.* TO `qpixel`@`%` | | GRANT ALL PRIVILEGES ON `qpixel`.* TO `qpixel`@`%` | | GRANT ALL PRIVILEGES ON `qpixel_dev`.* TO `qpixel`@`%` | | GRANT ALL PRIVILEGES ON `qpixel_test`.* TO `qpixel`@`%` | +---------------------------------------------------------+