When I set the environment variable to the activeadmin page, it was not set properly, so when I execute db: seed, an error occurs.
Since the administrator account of activeadmin is described in the seed file, if this cannot be executed, the account will not be created and it is a problem.
Is there a way to solve this?

The errors that occur on the terminal are as follows.

Access denied for user'root' @'localhost' (using password: YES)
Corresponding source code


unless AdminUser.find_by (email: ENV ['KEY'])
  AdminUser.create! (Email: ENV ['KEY'], password: ['SECRET_KEY'], password_confirmation: ['SECRET_KEY']) if Rails.env.development?
# Below this is the code to create the product name


  adapter: mysql2
  encoding: utf8
  pool:<% = ENV.fetch ("RAILS_MAX_THREADS") {5}%>
  username: root
  password: password:
  socket: /tmp/mysql.sock
<<: * default
  database: reservation_system_development
  email:<% = ENV ['KEY']%>
  password:<% = ENV ['SECRET_KEY']%>
  password_confirmation:<% = ENV ['SECRET_KEY']%>
test: test:
<<: * default
  database: reservation_system_test
<<: * default
  database: reservation_system_production
  username: reservation_system
  password:<% = ENV ['reservation_system_DATABASE_PASSWORD']%>
  email:<% = ENV ['KEY']%>
  password:<% = ENV ['SECRET_KEY']%>
  password_confirmation:<% = ENV ['SECRET_KEY']%>




class AdminUser</pre>
<p><br />
<pre><code data-language = "Ruby">ActiveAdmin.setup do | config |
  config.site_title = "Reservation System"
  config.authentication_method =: authenticate_admin_user!
  config.current_user_method =: current_admin_user
  config.logout_link_path =: destroy_admin_user_session_path
  config.root_to ='reservations # index'
  config.comments = false
  config.comments_menu = false
  config.batch_actions = true
  config.filter_attributes = [: encrypted_password,: password,: password_confirmation]
  config.localize_format =: long
What I tried

(1) By typing the following from the console, the desired data could be output.

  • ENV ['KEY']
    (2) If i comment out the following 3 lines of database.yml and execute db: seed, it will be "Validation failed: Please enter Password with 6 characters or more".
email:<% = ENV ['KEY']%>
  password:<% = ENV ['SECRET_KEY']%>
  password_confirmation:<% = ENV ['SECRET_KEY']%>
Supplementary information (FW/tool version, etc.)

We are using a Gem called Dotenv.

  • Answer # 1

    It is abnormal that databawe.yml has email or password_confirmation.
    username: password: In some cases host: socket :.