title: How to solve an error in Heroku's config/database.yml file "mapping values are not allowed in this context"
body: <p>I'm deploying an app to Heroku and it's mostly fine but for this error</p>
  
  <pre><code>mapping values are not allowed in this context at line 22 column 13 (Psych::SyntaxError)
  </code></pre>
  
  <p>The line they are referring to is line 22 of the database.yml file that Heroku itself is writing over my own file, as per standard practice.</p>
  
  <p>Jumping into <code>heroku run bash</code> and taking a look at the file in question:</p>
  
  <pre><code>&lt;%
  
  require 'cgi'
  require 'uri'
  
  begin
    uri = URI.parse(ENV["DATABASE_URL"])
  rescue URI::InvalidURIError
    raise "Invalid DATABASE_URL"
  end
  
  raise "No RACK_ENV or RAILS_ENV found" unless ENV["RAILS_ENV"] || ENV["RACK_ENV"]
  
  def attribute(name, value, force_string = false)
    if value
      value_string =
        if force_string
          '"' + value + '"'
        else
          value
        end
      "#{name}: #{value_string}"
    else
      ""
    end
  end
  
  adapter = uri.scheme
  adapter = "postgresql" if adapter == "postgres"
  
  database = (uri.path || "").split("/")[1]
  
  username = uri.user
  password = uri.password
  
  host = uri.host
  port = uri.port
  
  params = CGI.parse(uri.query || "")
  
  %&gt;
  
  &lt;%= ENV["RAILS_ENV"] || ENV["RACK_ENV"] %&gt;:
    &lt;%= attribute "adapter",  adapter %&gt;
    &lt;%= attribute "database", database %&gt;
    &lt;%= attribute "username", username %&gt;
    &lt;%= attribute "password", password, true %&gt;
    &lt;%= attribute "host",     host %&gt;
    &lt;%= attribute "port",     port %&gt;
  
  &lt;% params.each do |key, value| %&gt;
    &lt;%= key %&gt;: &lt;%= value.first %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Line 22 is </p>
  
  <pre><code>    "#{name}: #{value_string}"
  </code></pre>
  
  <p>Any suggestions as to how to resolve this problem?</p>