title: Rails 5.2 credentials:edit doesn't like secret_key_base
body: <p>I've been trying to debug my credentials file in my staging server. Whenever I try to edit the credentials on my staging server, I get the following error:</p>
  
  <p><code>
  /var/www/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/application.rb:583:in `validate_secret_key_base': `secret_key_base` for staging environment must be a type of String`
  </code></p>
  
  <p>My <code>database.yml</code> file looks like the following:</p>
  
  <pre><code>---
  default: &amp;default
    adapter: postgresql
  development:
    &lt;&lt;: *default
    database: dev_db
    host: &lt;%= Rails.application.credentials.database.fetch(:development).fetch(:host) %&gt;
    username: &lt;%= Rails.application.credentials.database.fetch(:development).fetch(:username) %&gt;
    password: &lt;%= Rails.application.credentials.database.fetch(:development).fetch(:password) %&gt;
    secret_key_base: &lt;%= Rails.application.credentials.secret_key_base.fetch(:development) %&gt;
  test:
    &lt;&lt;: *default
    database: test_db
    host: &lt;%= Rails.application.credentials.database.fetch(:development).fetch(:host) %&gt;
    username: &lt;%= Rails.application.credentials.database.fetch(:development).fetch(:username) %&gt;
    password: &lt;%= Rails.application.credentials.database.fetch(:development).fetch(:password) %&gt;
    secret_key_base: &lt;%= Rails.application.credentials.secret_key_base.fetch(:development) %&gt;
  staging:
    &lt;&lt;: *default
    database: &lt;%= Rails.application.credentials.database.fetch(:staging).fetch(:name) %&gt;
    host: &lt;%= Rails.application.credentials.database.fetch(:staging).fetch(:host) %&gt;
    username: &lt;%= Rails.application.credentials.database.fetch(:staging).fetch(:username) %&gt;
    password: &lt;%= Rails.application.credentials.database.fetch(:staging).fetch(:password) %&gt;
    secret_key_base: &lt;%= Rails.application.credentials.secret_key_base.fetch(:staging) %&gt;
  production:
    &lt;&lt;: *default
    database: &lt;%= Rails.application.credentials.database.fetch(:production).fetch(:name) %&gt;
    host: &lt;%= Rails.application.credentials.database.fetch(:production).fetch(:host) %&gt;
    username: &lt;%= Rails.application.credentials.database.fetch(:production).fetch(:username) %&gt;
    password: &lt;%= Rails.application.credentials.database.fetch(:production).fetch(:password) %&gt;
    secret_key_base: &lt;%= Rails.application.credentials.secret_key_base.fetch(:production) %&gt;
  </code></pre>
  
  <p>I think my staging's <code>secret_key_base</code> is of type <code>String</code>. I generated my <code>secret_key_base</code> using <code>rails secret</code>. Locally, when I bring up the rails console, I can view the <code>secret_key_base</code>s for my staging environment:</p>
  
  <pre><code>[1] pry(main)&gt; Rails.application.credentials.secret_key_base.fetch(:staging)
  \=&gt; "generated_using_rails_secret"
  </code></pre>
  
  <p>It returns a string but I still get the error message above whenever I try to access credentials in my staging environment.</p>